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:
@@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user