SecurityDescriptorUtils.cs 923 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Linq;
  3. using InABox.Clients;
  4. namespace InABox.Core
  5. {
  6. public static class SecurityDescriptorUtils
  7. {
  8. public static string Type(Type type)
  9. {
  10. type = type.BaseType?.GetGenericArguments().FirstOrDefault();
  11. if (type != null)
  12. {
  13. var caption = type.GetCustomAttributes(typeof(Caption), true).FirstOrDefault() as Caption;
  14. return caption != null ? caption.Text : type.EntityName();
  15. }
  16. return "General";
  17. }
  18. public static string Code(Type type)
  19. {
  20. return type.EntityName().Split('.').Last();
  21. }
  22. public static string Description(Type type)
  23. {
  24. var caption = type.GetCustomAttributes(typeof(Caption), true).FirstOrDefault() as Caption;
  25. return caption != null ? caption.Text : type.EntityName();
  26. }
  27. }
  28. }