Exemple #1
0
        public Bouncer([NotNull] Action <BouncerBuilder <T> > builder)
        {
            var rules = new BouncerBuilder <T>();

            builder(rules);
            _policies = rules.Build();
        }
Exemple #2
0
 public static BouncerPolicyBuilder <T> BlockNull <T>(this BouncerBuilder <T> builder)
 {
     return
         (builder
          .Block(IsNullExpression.Create <T>())
          .WithMessage($"{typeof(T).ToPrettyString()} must not be null.")
          .BreakOnFailure());
 }
Exemple #3
0
        public static BouncerPolicyBuilder <T> Block <T>(this BouncerBuilder <T> builder, Expression <Func <T, bool> > expression)
        {
            var notExpression = Expression.Lambda <Func <T, bool> >(Expression.Not(expression.Body), expression.Parameters[0]);

            return(builder.Ensure(notExpression));
        }
Exemple #4
0
 public static BouncerPolicyBuilder <T> Ensure <T>(this BouncerBuilder <T> builder, Expression <Func <T, bool> > expression)
 {
     return(builder.Policy(expression));
 }