예제 #1
0
 /// <summary>
 ///     Checks the value of the supplied string <paramref name="value" /> and throws an
 ///     <see cref="System.ArgumentException" /> if it is <see langword="null" /> or empty.
 /// </summary>
 /// <param name="value">The string value to check.</param>
 /// <param name="variableName">The variable name.</param>
 /// <param name="message">The message to include in exception description</param>
 /// <param name="options">The value trimming options.  Default is <see cref="TrimOption.DoTrim" />.</param>
 /// <exception cref="System.ArgumentException">
 ///     If the supplied <paramref name="value" /> is <see langword="null" /> or empty.
 /// </exception>
 static public void AgainstNullOrEmpty(
     string value, string variableName, string message,
     TrimOption options = TrimOption.DoTrim)
 {
     if (options == TrimOption.DoTrim && string.IsNullOrWhiteSpace(value) || string.IsNullOrEmpty(value))
     {
         throw new ArgumentException(message, variableName);
     }
 }
예제 #2
0
 /// <summary>
 ///     Checks the value of the supplied string <paramref name="value" /> and throws an
 ///     <see cref="System.ArgumentException" /> if it is <see langword="null" /> or empty.
 /// </summary>
 /// <param name="value">The string value to check.</param>
 /// <param name="variableName">The argument name.</param>
 /// <param name="options">The value trimming options.  Default is <see cref="TrimOption.DoTrim" />.</param>
 /// <exception cref="System.ArgumentException">
 ///     If the supplied <paramref name="value" /> is <see langword="null" /> or empty.
 /// </exception>
 static public void AgainstNullOrEmpty(string value, string variableName, TrimOption options = TrimOption.DoTrim)
 {
     if (options == TrimOption.DoTrim && string.IsNullOrWhiteSpace(value) || string.IsNullOrEmpty(value))
     {
         string message = string.Format(
             CultureInfo.InvariantCulture,
             "'{0}' cannot be null or resolve to an empty string : '{1}'.", variableName, value);
         throw new ArgumentException(message, variableName);
     }
 }