Example #1
0
 //TODO rename AgainstInvalidOperation
 /// <summary>
 /// Throws an InvalidOperationException if the testForFailure is true
 /// </summary>
 /// <param name="testForFailure">A comparator which returnstrue if this method is to throw an InvalidOperationException</param>
 /// <param name="failureMessage">The message to include in the exception.  This message is parsed using string.Format</param>
 /// <param name="failureMessageFormatItems">Parameters for inclusion in the string.Format string parse</param>
 /// <exception cref="InvalidOperationException">Thrown if the testForFailure returns true.</exception>
 public static void AgainstInvalidState(ArgumentComparator testForFailure, string failureMessage, params object[] failureMessageFormatItems)
 {
     if (testForFailure())
     {
         throw new InvalidOperationException(string.Format(
             System.Globalization.CultureInfo.InvariantCulture,
             failureMessage,
             failureMessageFormatItems));
     }
 }
Example #2
0
 /// <summary>
 /// Throws an InvalidOperationException if the testForFailure is true
 /// </summary>
 /// <param name="testForFailure">A comparator which returnstrue if this method is to throw an InvalidOperationException</param>
 /// <param name="failureMessage">The message to include in the exception.  This message is parsed using string.Format</param>
 /// <param name="failureMessageFormatItems">Parameters for inclusion in the string.Format string parse</param>
 /// <exception cref="InvalidOperationException">Thrown if the testForFailure returns true.</exception>
 public static void AgainstInvalidState(ArgumentComparator testForFailure, string failureMessage, params object[] failureMessageFormatItems) //TODO rename AgainstInvalidOperation
 {
     if (testForFailure())
     {
         throw new InvalidOperationException(string.Format(
                                                 System.Globalization.CultureInfo.InvariantCulture,
                                                 failureMessage,
                                                 failureMessageFormatItems));
     }
 }
Example #3
0
 /// <summary>
 /// Throws an exception if the testForFailure is true.
 /// </summary>
 /// <param name="testForFailure">A comparator which returns true if this method is to throw an error</param>
 /// <param name="failureMessage">A custom message to provide with the exception.</param>
 /// <param name="parameterName">The name of the parameter within the calling method.</param>
 public static void AgainstBadArgument(string parameterName, ArgumentComparator testForFailure, string failureMessage, params object[] failureMessageFormatItems)
 {
     if (testForFailure())
     {
         throw new ArgumentException(string.Format(
             System.Globalization.CultureInfo.InvariantCulture,
             failureMessage,
             failureMessageFormatItems),
                                     parameterName);
     }
 }
Example #4
0
 /// <summary>
 /// Throws an exception if the testForFailure is true.
 /// </summary>
 /// <param name="testForFailure">A comparator which returns true if this method is to throw an error</param>
 /// <param name="failureMessage">A custom message to provide with the exception.</param>
 /// <param name="parameterName">The name of the parameter within the calling method.</param>
 public static void AgainstBadArgument(string parameterName, ArgumentComparator testForFailure, string failureMessage, params object[] failureMessageFormatItems)
 {
     if (testForFailure())
     {
         throw new ArgumentException(string.Format(
                                         System.Globalization.CultureInfo.InvariantCulture,
                                         failureMessage,
                                         failureMessageFormatItems),
                                     parameterName);
     }
 }