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 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)); }