Make enums be considered userdata, and not numbers. Allow C# functions that consume enums to use both numbers and userdata

This commit is contained in:
2019-01-16 10:50:22 +01:00
parent 0a034013ea
commit 2ef06b3fd7
2 changed files with 8 additions and 7 deletions

View File

@@ -106,7 +106,6 @@ namespace Upsilon.BoundTypes
throw new Exception("Trying to bind an enum with a type that's not an enum");
Properties = new Dictionary<string, UserDataBoundProperty>();
var enumUnderlyingType = Enum.GetUnderlyingType(enumType);
var enumValues = Enum.GetValues(enumType);
Name = name;
@@ -119,11 +118,12 @@ namespace Upsilon.BoundTypes
Properties.Add(valueName, new UserDataBoundProperty()
{
Name = valueName,
ActualType = enumUnderlyingType.ToString(),
Type = Type.Number
ActualType = enumType.ToString(),
Type = Type.UserData
});
}
}
public UserDataBoundEnumDefinition(IEnumerable<string> values, string name) : base(name, new Dictionary<string, UserDataBoundProperty>())
{
Properties = new Dictionary<string, UserDataBoundProperty>();
@@ -131,11 +131,11 @@ namespace Upsilon.BoundTypes
foreach (var value in values)
{
var valueName = value.ToString().ToLowerInvariant();
var valueName = value.ToLowerInvariant();
Properties.Add(valueName, new UserDataBoundProperty()
{
Name = valueName,
Type = Type.Number
Type = Type.UserData
});
}
}