Exemplo n.º 1
0
 public UserRecordPermission(AccessType accessTypes, EntityMemberMask memberMask = null)
 {
     Peek = new OperationPermission(AccessType.Peek, accessTypes.IsSet(AccessType.Peek), memberMask);
       ReadStrict = new OperationPermission(AccessType.ReadStrict, accessTypes.IsSet(AccessType.ReadStrict), memberMask);
       UpdateStrict = new OperationPermission(AccessType.UpdateStrict, accessTypes.IsSet(AccessType.UpdateStrict), memberMask);
       AccessTypes = accessTypes;
 }
Exemplo n.º 2
0
 public static EntityMemberMask Create(EntityInfo entity, string propertiesOrGroups)
 {
     var invalidNames = new StringList();
       var mask = new EntityMemberMask(propertiesOrGroups, entity);
       var props = propertiesOrGroups.SplitNames(',', ';');
       foreach (var name in props) {
     //first try member
     if (string.IsNullOrWhiteSpace(name))
       continue;
     var grp = entity.GetPropertyGroup(name);
     if (grp != null) {
       foreach (var m in grp.Members)
     mask.Set(m);
       continue;
     }
     var member = entity.GetMember(name);
     if (member != null) {
       mask.Set(member);
       continue;
     }
     //name is invalid
     invalidNames.Add(name);
       }
       if (invalidNames.Count > 0)
     Util.Throw("Properties/subgroups [{0}] not found in entity {1}.", string.Join(",", invalidNames), entity.EntityType);
       return mask;
 }
Exemplo n.º 3
0
 public void Init(EntityModel model)
 {
     if (_initialized) return;
       _initialized = true;
       var entInfo = model.GetEntityInfo(EntityType);
       Util.Check(entInfo != null, "Entity {0} is not part of entity model.", EntityType);
       if (!string.IsNullOrWhiteSpace(Properties))
     MemberMask = EntityMemberMask.Create(entInfo, Properties);
 }
Exemplo n.º 4
0
 public OperationPermission(AccessType operation, bool allow, EntityMemberMask mask = null)
 {
     Util.Check((operation | AllowedOperations) == AllowedOperations,
     "Invalid operation value - only Peek, ReadStrict and UpdateStrict allowed.");
       Operation = AllowedOperations & operation;
       Mask = mask;
       if(!allow)
     Status = PermissionStatus.Denied;
       else if(Mask == null)
     Status = PermissionStatus.AllowAll;
       else
     Status = PermissionStatus.AllowMasked;
 }
Exemplo n.º 5
0
 internal void Merge(OperationPermission other)
 {
     Util.Check(this.Operation == other.Operation, "Operation must match for merge.");
       switch(Status) {
     case PermissionStatus.AllowAll: return;
     case PermissionStatus.Denied:
       this.Status = other.Status;
       this.Mask = other.Mask;
       return;
     case PermissionStatus.AllowMasked:
       switch(other.Status) {
     case PermissionStatus.Denied: return;
     case PermissionStatus.AllowAll: this.Status = PermissionStatus.AllowAll; return;
     case PermissionStatus.AllowMasked: this.Mask.Or(other.Mask); return;
       }
       break;
       }
 }
Exemplo n.º 6
0
        public static EntityMemberMask Create(EntityInfo entity, string propertiesOrGroups)
        {
            var invalidNames = new StringList();
            var mask         = new EntityMemberMask(propertiesOrGroups, entity);
            var props        = propertiesOrGroups.SplitNames(',', ';');

            foreach (var name in props)
            {
                //first try member
                if (string.IsNullOrWhiteSpace(name))
                {
                    continue;
                }
                var grp = entity.GetPropertyGroup(name);
                if (grp != null)
                {
                    foreach (var m in grp.Members)
                    {
                        mask.Set(m);
                    }
                    continue;
                }
                var member = entity.GetMember(name);
                if (member != null)
                {
                    mask.Set(member);
                    continue;
                }
                //name is invalid
                invalidNames.Add(name);
            }
            if (invalidNames.Count > 0)
            {
                Util.Throw("Properties/subgroups [{0}] not found in entity {1}.", string.Join(",", invalidNames), entity.EntityType);
            }
            return(mask);
        }
Exemplo n.º 7
0
 public UserEntityTypePermission(AccessType accessTypes, EntityMemberMask memberMask = null)
     : base(accessTypes, memberMask)
 {
 }
Exemplo n.º 8
0
 public EntityMemberMask And(EntityMemberMask other)
 {
     Key = null;
       Bits.And(other.Bits);
       return this;
 }
Exemplo n.º 9
0
 public EntityMemberMask(EntityMemberMask clone)
 {
     Key = clone.Key;
       Entity = clone.Entity;
       Bits = new CustomBitArray(clone.Bits);
 }
Exemplo n.º 10
0
 public EntityMemberMask And(EntityMemberMask other)
 {
     Key = null;
     Bits.And(other.Bits);
     return(this);
 }
Exemplo n.º 11
0
 public EntityMemberMask(EntityMemberMask clone)
 {
     Key    = clone.Key;
     Entity = clone.Entity;
     Bits   = new CustomBitArray(clone.Bits);
 }