コード例 #1
0
        /// <summary>
        /// Add a predicate rule based on a Func that will be called when validation occurs.
        /// </summary>
        /// <param name="validateFor"><see cref="Func{T, TR}"/> that will be called for validation.</param>
        /// <returns><see cref="IRuleBuilderOptions{T, TR}"/> that can be used to fluently configure options for the rule.</returns>
        public IRuleBuilderOptions <T, object> AddRule(Func <T, bool> validateFor)
        {
            var rule = CommandPredicateRule <T> .Create(validateFor);

            AddRule(rule);

            return(new RuleBuilder <T, object>(rule));
        }
コード例 #2
0
#pragma warning restore 1591 // Xml Comments


        /// <summary>
        /// Create a <see cref="CommandPredicateRule{T}"/> from a <see cref="Func{T, TR}"/> to use for validation
        /// </summary>
        /// <param name="validateFor"><see cref="Func{T, TR}"/> to use for validation</param>
        /// <returns>A <see cref="CommandPredicateRule{T}"/></returns>
        public static CommandPredicateRule <T> Create(Func <T, bool> validateFor)
        {
            var rule = new CommandPredicateRule <T>(validateFor);

            return(rule);
        }