예제 #1
0
        /// <summary>
        /// Creates a new list of requirements associated with this <see cref="Validator{TObject}"/> with a specified key
        /// </summary>
        /// <typeparam name="TProperty">The type of the property to validate</typeparam>
        /// <param name="expression">An expression defining the property to validate</param>
        /// <param name="key">The key to identify requirements in this list by</param>
        /// <returns>A <see cref="IRequirementList{TObject,TProperty}"/> associated with the specified property</returns>
        protected IRequirementList <TTarget, TProperty> Require <TProperty>(Func <TTarget, TProperty> expression, string key)
        {
            var list = new RequirementList <TTarget, TProperty>(expression, key);

            requirements.Add(list);
            return(list);
        }
예제 #2
0
        /// <summary>
        /// Creates a new list of requirements associated with this <see cref="Validator{TObject}"/>
        /// </summary>
        /// <typeparam name="TProperty">The type of the property to validate</typeparam>
        /// <param name="expression">An expression defining the property to validate</param>
        /// <returns>A <see cref="IRequirementList{TObject,TProperty}"/> associated with the specified property</returns>
        protected IRequirementList <TTarget, TProperty> Require <TProperty>(Expression <Func <TTarget, TProperty> > expression)
        {
            var list = new RequirementList <TTarget, TProperty>(expression);

            requirements.Add(list);
            return(list);
        }