/// <summary>
        /// Validates that the parameter is equal to <paramref name="value" />. Otherwise, an <see cref="ArgumentException" /> is thrown.
        /// </summary>
        /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param>
        /// <param name="value">The value the parameter must be equal to.</param>
        /// <param name="ignoreCase">Whether or not to ignore case.</param>
        /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns>
        /// <exception cref="System.ArgumentException">Thrown when parameter is not equal to <paramref name="value" />.</exception>
        public static ParameterValidator <string> IsEqualTo(this ParameterValidator <string> validator, string value, bool ignoreCase)
        {
            if (value != null)
            {
                string exceptionMessage = string.Format(ExceptionMessages.VALUE_MUST_BE_EQUAL_TO, value);

                return(validator.IsEqualTo(value, ignoreCase, exceptionMessage));
            }

            return(validator);
        }
コード例 #2
0
 /// <summary>
 ///  Validates that the parameter is equal to <typeparamref name="TType" />. Otherwise, an <see cref="System.ArgumentException" /> is thrown.
 /// </summary>
 /// <typeparam name="TType">The expected value.</typeparam>
 /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param>
 /// <param name="exceptionMessage">The exception message.</param>
 /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns>
 /// <exception cref="ArgumentException">Thrown when the parameter is not equal to <typeparamref name="TType" />.</exception>
 public static ParameterValidator <Type> IsEqualTo <TType>(this ParameterValidator <Type> validator, string exceptionMessage)
 {
     return(validator.IsEqualTo(typeof(TType), exceptionMessage));
 }
コード例 #3
0
 /// <summary>
 ///  Validates that the parameter is equal to <typeparamref name="TType" />. Otherwise, an <see cref="System.ArgumentException" /> is thrown.
 /// </summary>
 /// <typeparam name="TType">The expected value.</typeparam>
 /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param>
 /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns>
 /// <exception cref="ArgumentException">Thrown when the parameter is not equal to <typeparamref name="TType" />.</exception>
 public static ParameterValidator <Type> IsEqualTo <TType>(this ParameterValidator <Type> validator)
 {
     return(validator.IsEqualTo(typeof(TType)));
 }