Esempio n. 1
0
        /// <summary>
        /// This time we will not prevent executing the method code, but
        /// just collect the violated rules and print them to the console.
        /// The rule is a custom one that checks for a specific string inside
        /// a specific property. You might reuse such logic by inheriting
        /// from RuleBase and initialize the CheckExpression inside the
        /// constructor.
        /// </summary>
        /// <param name="customer"></param>
        internal IEnumerable <RuleValidationResult> CheckCustomerWithCustomRule(MyCustomer customer)
        {
            var results = Bouncer
                          .ForMessages(() => customer)
                          .Assert(new RuleBase <MyCustomer, object>
            {
                Message         = "Sven cannot enter this method",
                CheckExpression = (x, y) => x.FullName != "Sven"
            }).Results;

            return(results);
        }
Esempio n. 2
0
        internal IEnumerable <RuleValidationResult> InsertCustomer(MyCustomer customer)
        {
            var results = Bouncer.ForMessages(() => customer).Assert().Results;

            return(results);
        }
Esempio n. 3
0
        public IEnumerable <RuleValidationResult> CheckCustomerWithWithMethodAttributes(string customerId, int amount, MyCustomer theCustomer)
        {
            var results = Bouncer
                          .ForMessages(() => customerId)
                          .ForMessages(() => amount)
                          .ForMessages(() => theCustomer)
                          .Assert().Results;

            return(results);
        }
Esempio n. 4
0
 /// <summary>
 /// This time we will not prevent executing the method code, but
 /// just collect the violated rules and print them to the console.
 /// </summary>
 /// <param name="customer"></param>
 internal IEnumerable <RuleValidationResult> CheckCustomerProperties(MyCustomer customer)
 {
     return(Bouncer.ForMessages(() => customer).Assert().Results);
 }