Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EqualityRule{T}"/> class.
        /// </summary>
        /// <param name="comparer">An equality comparer.</param>
        /// <param name="name">The rule name.</param>
        public EqualityRule(IEqualityComparer <T> comparer, string name)
        {
            this.comparer = comparer ?? throw new ArgumentNullException(nameof(comparer));
            Name          = name;

            resultFactory = new EqualityResultFactory();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ParentEqualityRule{TParent, TValue}"/> class.
        /// </summary>
        /// <param name="valueProvider">A service which gets the value to be compared from the parent object.</param>
        /// <param name="valueRule">A equality rule which tests the 'child' value.</param>
        public ParentEqualityRule(IGetsValueFromParent <TParent, TValue> valueProvider,
                                  IEqualityRule <TValue> valueRule)
        {
            this.valueProvider = valueProvider ?? throw new ArgumentNullException(nameof(valueProvider));
            this.valueRule     = valueRule ?? throw new ArgumentNullException(nameof(valueRule));

            resultFactory = new EqualityResultFactory();
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RuleNameChangingDecorator{T}"/> class.
 /// </summary>
 /// <param name="wrapped">The wrapped equality rule.</param>
 /// <param name="nameTransformer">A function which transforms the rule name.</param>
 public RuleNameChangingDecorator(IEqualityRule <T> wrapped, Func <string, string> nameTransformer)
 {
     this.wrapped         = wrapped ?? throw new ArgumentNullException(nameof(wrapped));
     this.nameTransformer = nameTransformer ?? throw new ArgumentNullException(nameof(nameTransformer));
     resultFactory        = new EqualityResultFactory();
 }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MultipleEqualityRuleRunner{T}"/> class.
        /// </summary>
        /// <param name="rules">The child rules.</param>
        public MultipleEqualityRuleRunner(IEnumerable <IEqualityRule <T> > rules)
        {
            this.rules = rules?.ToArray() ?? throw new ArgumentNullException(nameof(rules));

            resultFactory = new EqualityResultFactory();
        }