diff --git a/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs b/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs index c412235..5666d5d 100644 --- a/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs +++ b/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs @@ -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(); - 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 values, string name) : base(name, new Dictionary()) { Properties = new Dictionary(); @@ -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 }); } } diff --git a/Upsilon/StandardLibraries/StaticScope.cs b/Upsilon/StandardLibraries/StaticScope.cs index c61eeab..40d4f73 100644 --- a/Upsilon/StandardLibraries/StaticScope.cs +++ b/Upsilon/StandardLibraries/StaticScope.cs @@ -141,6 +141,9 @@ namespace Upsilon.StandardLibraries public static Type DeriveValidTypes(System.Type type) { + if (type.IsEnum) + return Type.UserData | Type.Number; + var typeCode = System.Type.GetTypeCode(type); switch (typeCode) { @@ -181,8 +184,6 @@ namespace Upsilon.StandardLibraries if (type == typeof(IIterable)) return Type.Table | Type.UserData; - if (type.IsEnum) - return Type.UserData | Type.Number; if (typeof(IEnumerable).IsAssignableFrom(type)) return Type.Table | Type.UserData; return Type.UserData;