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); }
public EntityRecord(EntityInfo entityInfo, EntityStatus status) { _status = status; EntityInfo = entityInfo; InitValuesStorage(); MaskMembersRead = new EntityMemberMask(this.EntityInfo.PersistentValuesCount); }
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; }
//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); }
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); } }
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; } }
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)); }
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
public UserEntityTypePermission(AccessType accessTypes, EntityMemberMask memberMask = null) : base(accessTypes, memberMask) { }
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]); }