Пример #1
0
        /// <inheritdoc/>
        public IRuleBuilder <TContext, TSubject> WithSpecification(ISpecification <TSubject> specification)
        {
            var rule = SpecificationRule.CreateSpecificationRule(specification, _name);

            _addRuleCallBack(rule);
            return(new RuleBuilder <TContext, TSubject> (rule));
        }
Пример #2
0
        /// <summary>
        /// Creates an instance of a Specification Rule
        /// </summary>
        /// <typeparam name="TSubject">Type of the subject of the rule.</typeparam>
        /// <param name="specification">Specification rule must meet.</param>
        /// <param name="ruleName">Name of the rule</param>
        /// <returns>A <see cref="SpecificationRule">Specification Rule</see>.</returns>
        public static SpecificationRule CreateSpecificationRule <TSubject> (ISpecification <TSubject> specification, string ruleName)
        {
            Check.IsNotNull(specification, "specification is required.");

            var specificationRule = new SpecificationRule(ruleName)
            {
                WhenClause = ctx => specification.IsSatisfiedBy(( TSubject )ctx.Subject)
            };

            return(specificationRule);
        }