You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

20 lines
472 B

  1. using System;
  2. using System.Reflection;
  3. using SUISS.Core.Utilities;
  4. public static class EnumUtilities
  5. {
  6. public static T GetEnumProp<T>(Enum value) where T : Attribute
  7. {
  8. T result = (T)((object)null);
  9. Type type = value.GetType();
  10. FieldInfo field = type.GetCompatibleTypeInfo().GetField(value.ToString());
  11. T[] array = field.GetCustomAttributes(typeof(T), false) as T[];
  12. if (array.Length > 0)
  13. {
  14. result = array[0];
  15. }
  16. return result;
  17. }
  18. }