예제 #1
0
        public static string BuildCrudKey(EntityStatus status, string entityName, EntityMemberMask mask)
        {
            var maskStr = status == EntityStatus.Modified ? mask.AsHexString() : "(nomask)";
            var key     = $"CRUD/{entityName}/{status}/Mask:{maskStr}";

            return(key);
        }
예제 #2
0
 public EntityRecord(EntityInfo entityInfo, EntityStatus status)
 {
     _status    = status;
     EntityInfo = entityInfo;
     InitValuesStorage();
     MaskMembersRead = new EntityMemberMask(this.EntityInfo.PersistentValuesCount);
 }
예제 #3
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;
 }
예제 #4
0
        //Creates a clone from a copy
        public EntityRecord(EntityRecord copyFrom)
        {
            this.EntityInfo = copyFrom.EntityInfo;
            _primaryKey     = copyFrom.PrimaryKey;
            this._status    = EntityStatus.Loaded;
            var valuesCount = EntityInfo.PersistentValuesCount;

            this.ValuesOriginal = new object[valuesCount];
            this.ValuesModified = new object[valuesCount];
            Array.Copy(copyFrom.ValuesOriginal, ValuesOriginal, valuesCount);
            this.ValuesTransient = new object[EntityInfo.TransientValuesCount];
            MaskMembersRead      = new EntityMemberMask(valuesCount);
        }
예제 #5
0
        private bool _initialized; //a flag to avoid multiple initialization

        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);
            }
        }
예제 #6
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;
     }
 }
예제 #7
0
        public static UserRecordPermission Create(EntityInfo entity, string properties, AccessType accessType)
        {
            if (string.IsNullOrWhiteSpace(properties))
            {
                if (accessType.IsSet(AccessType.Update))
                {
                    return(UserRecordPermission.AllowAll);
                }
                if (accessType.IsSet(AccessType.ReadStrict))
                {
                    return(UserRecordPermission.AllowReadAll);
                }
                if (accessType.IsSet(AccessType.Peek))
                {
                    return(UserRecordPermission.AllowPeekAll);
                }
                return(UserRecordPermission.AllowNone);
            }
            var mask = EntityMemberMask.Create(entity, properties);

            return(new UserRecordPermission(accessType, mask));
        }
예제 #8
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;
            }
        } //method
예제 #9
0
 public UserEntityTypePermission(AccessType accessTypes, EntityMemberMask memberMask = null)
     : base(accessTypes, memberMask)
 {
 }
예제 #10
0
        public IEntityRecordContainer SelectByPrimaryKey(EntityInfo entity, object[] keyValues,
                                                         LockType lockType = LockType.None, EntityMemberMask mask = null)
        {
            var cmd  = LinqCommandFactory.CreateSelectByPrimaryKey(this, entity.PrimaryKey, lockType, keyValues);
            var list = (IList)ExecuteLinqCommand(cmd);

            if (list.Count == 0)
            {
                return(null);
            }
            return((IEntityRecordContainer)list[0]);
        }