BaseSecurityDescriptor.cs 964 B

12345678910111213141516171819202122232425262728
  1. using System.Linq;
  2. namespace InABox.Core
  3. {
  4. public abstract class BaseSecurityDescriptor<T> : ISecurityDescriptor where T : LicenseToken
  5. {
  6. public virtual bool Visible => SecurityDescriptorUtils.IsSupported(GetType());
  7. public virtual string Category => "";
  8. public string Type => typeof(T).GetCaption(); //SecurityDescriptorUtils.Type(this.GetType());
  9. public string Code => SecurityDescriptorUtils.Code(GetType());
  10. public string Description => SecurityDescriptorUtils.Description(GetType());
  11. public abstract bool Value { get; }
  12. public bool HasScope(SecurityDescriptorScope scope)
  13. {
  14. var attribute =
  15. GetType().GetCustomAttributes(typeof(SecurityDescriptorScopeAttribute), true).FirstOrDefault() as SecurityDescriptorScopeAttribute;
  16. if (attribute == null)
  17. return true;
  18. return attribute.HasScope(scope);
  19. }
  20. }
  21. }