Esempio n. 1
0
        public AuthCache(SchemaBuilder sb, Func <R, K> toKey, Func <K, R> toEntity,
                         Expression <Func <R, R, bool> > isEquals, IMerger <K, A> merger, bool invalidateWithTypes, Coercer <A, K>?coercer = null)
        {
            this.ToKey    = toKey;
            this.ToEntity = toEntity;
            this.merger   = merger;
            this.IsEquals = isEquals;
            this.coercer  = coercer ?? Coercer <A, K> .None;

            runtimeRules = sb.GlobalLazy(this.NewCache,
                                         invalidateWithTypes ?
                                         new InvalidateWith(typeof(RT), typeof(RoleEntity), typeof(RuleTypeEntity)) :
                                         new InvalidateWith(typeof(RT), typeof(RoleEntity)), AuthLogic.NotifyRulesChanged);
        }
Esempio n. 2
0
        public AuthCache(SchemaBuilder sb, Func <R, K> toKey, Func <K, R> toEntity, IMerger <K, A> merger, bool invalidateWithTypes, Coercer <A, K> coercer = null)
        {
            this.ToKey    = toKey;
            this.ToEntity = toEntity;
            this.merger   = merger;
            this.coercer  = coercer ?? Coercer <A, K> .None;

            sb.Include <RT>();

            runtimeRules = sb.GlobalLazy(this.NewCache,
                                         invalidateWithTypes ?
                                         new InvalidateWith(typeof(RT), typeof(RoleEntity), typeof(RuleTypeEntity)) :
                                         new InvalidateWith(typeof(RT), typeof(RoleEntity)), AuthLogic.NotifyRulesChanged);

            sb.AddUniqueIndex <RT>(rt => new { rt.Resource, rt.Role });

            sb.Schema.Table <R>().PreDeleteSqlSync += new Func <Entity, SqlPreCommand>(AuthCache_PreDeleteSqlSync);
        }