/// <summary> /// Throws a System.ArgumentOutOfRangeException with the specified message. The parameter name /// for the exception will be the value of ensureArg.ArgumentName. /// </summary> /// <typeparam name="T">The type parameter of the IEnsureArg instance.</typeparam> /// <param name="ensureArg">The IEnsureArg instance to throw an exception for.</param> /// <param name="min">The minimum value ensureArg.Value was outside to cause this error to be thrown.</param> /// <param name="max">The maximum value ensureArg.Value was outside to cause this error to be thrown.</param> /// <param name="exceptionMessage"> /// The message to use in the exception. If no exception message is supplied then /// ensureArg.ExceptionMessage will be used. /// </param> public static void ThrowArgumentOutOfRangeException <T>(this IEnsureArg <T> ensureArg, T min, T max, string exceptionMessage = null) { string message = ensureArg.FormatArgumentOutOfRangeException(min, max, exceptionMessage); throw new ArgumentOutOfRangeException(ensureArg.ArgumentName, ensureArg.Value, message); }