@@ -55,8 +55,8 @@ public static MethodInfo PrepareConvert(this Type fromType, Type toType)
55
55
public static String GetOfficialName ( this MemberInfo member )
56
56
{
57
57
var names = member . GetCustomAttributes < DomNameAttribute > ( ) ;
58
- var officalNameAttribute = names . FirstOrDefault ( ) ;
59
- return officalNameAttribute ? . OfficialName ?? member . Name ;
58
+ var officialNameAttribute = names . FirstOrDefault ( ) ;
59
+ return officialNameAttribute ? . OfficialName ?? member . Name ;
60
60
}
61
61
62
62
public static String GetOfficialName ( this Type currentType , Type baseType )
@@ -87,6 +87,18 @@ public static String GetOfficialName(this Type currentType, Type baseType)
87
87
return name ;
88
88
}
89
89
90
+ public static String GetOfficialName ( this Enum value )
91
+ {
92
+ var enumType = value . GetType ( ) ;
93
+ var member = enumType . GetMember ( value . ToString ( ) ) . FirstOrDefault ( ) ;
94
+
95
+ // if the enum value does not have a DomNameAttribute, calling member.GetOfficialName() would return the value name
96
+ // to allow previous behaviour to be preserved, if the DomNameAttribute is not present then null will be returned
97
+ IEnumerable < DomNameAttribute > names = member . GetCustomAttributes < DomNameAttribute > ( ) ;
98
+ var officialNameAttribute = names . FirstOrDefault ( ) ;
99
+ return officialNameAttribute ? . OfficialName ;
100
+ }
101
+
90
102
public static PropertyInfo GetInheritedProperty ( this Type type , String propertyName , BindingFlags bindingAttr = BindingFlags . Public | BindingFlags . Instance )
91
103
{
92
104
if ( type . GetTypeInfo ( ) . IsInterface )
0 commit comments