UserSecurityToken.cs 1005 B

123456789101112131415161718192021222324252627282930313233
  1. using System.Linq;
  2. namespace InABox.Core
  3. {
  4. [UserTracking(typeof(User))]
  5. [Caption("Security Overrides")]
  6. public class UserSecurityToken : Entity, IPersistent, IRemotable, ILicense<CoreLicense>
  7. {
  8. [NullEditor]
  9. [EntityRelationship(DeleteAction.Cascade)]
  10. public UserLink User { get; set; }
  11. [ComboLookupEditor(typeof(SecurityRestrictionGenerator))]
  12. public string Descriptor { get; set; }
  13. [CheckBoxEditor]
  14. public bool Enabled { get; set; }
  15. public override string ToString()
  16. {
  17. return Descriptor;
  18. }
  19. private class SecurityRestrictionGenerator : LookupGenerator<object>
  20. {
  21. public SecurityRestrictionGenerator(object[] items) : base(items)
  22. {
  23. foreach (var descriptor in Security.Descriptors.Where(x => x.HasScope(SecurityDescriptorScope.User)))
  24. AddValue(descriptor.Code, descriptor.Description);
  25. }
  26. }
  27. }
  28. }