EnumValueAttribute.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. namespace CefSharpWrap.AceEditorWrap
  3. {
  4. internal class EnumValueAttribute : Attribute
  5. {
  6. public string Value { get; }
  7. public EnumValueAttribute(string value)
  8. {
  9. Value = value;
  10. }
  11. }
  12. internal static class EnumExtensionMethod
  13. {
  14. public static string GetEnumValue(this AceEditorTheme me)
  15. {
  16. var type = me.GetType();
  17. var memInfo = type.GetMember(me.ToString());
  18. var attributes = memInfo[0].GetCustomAttributes(typeof(EnumValueAttribute), false);
  19. var value = ((EnumValueAttribute)attributes[0]).Value;
  20. return value;
  21. }
  22. public static string GetEnumValue(this AceEditorMode me)
  23. {
  24. var type = me.GetType();
  25. var memInfo = type.GetMember(me.ToString());
  26. var attributes = memInfo[0].GetCustomAttributes(typeof(EnumValueAttribute), false);
  27. var value = ((EnumValueAttribute)attributes[0]).Value;
  28. return value;
  29. }
  30. }
  31. }