public static TsEnumValue CreateFrom(FieldInfo enumValueField, ITsConfigurationProvider configurationProvider) { var enumValue = new TsEnumValue(); var enumValueConfiguration = configurationProvider.GetEnumValueConfiguration(enumValueField); enumValue.Name = enumValueConfiguration.Name; enumValue.Value = enumValueConfiguration.Value; return(enumValue); }
public static TsEnum CreateFrom <T>(TypeResolver typeResolver, ITsConfigurationProvider configurationProvider) { var @enum = new TsEnum((TsBasicType)typeResolver.ResolveType(typeof(T))); var enumType = typeof(T); var enumTypeInfo = enumType.GetTypeInfo(); @enum.Values = enumTypeInfo.DeclaredFields .Where(fieldInfo => fieldInfo.IsLiteral) .Select(fieldInfo => TsEnumValue.CreateFrom(fieldInfo, configurationProvider)) .Where(enumValue => enumValue != null) .ToList(); return(@enum); }