Exemplo n.º 1
0
 /// <summary>
 /// Checks the value of the supplied <see cref="ICollection"/> <paramref name="argument"/> and throws
 /// an <see cref="ArgumentNullException"/> if it is <see langword="null"/> or contains no elements.
 /// </summary>
 /// <param name="argument">The array or collection to check.</param>
 /// <param name="name">The argument name.</param>
 /// <param name="message">An arbitrary message that will be passed to any thrown <see cref="System.ArgumentNullException"/>.</param>
 /// <exception cref="System.ArgumentNullException">
 /// If the supplied <paramref name="argument"/> is <see langword="null"/> or
 /// contains no elements.
 /// </exception>
 public static void ArgumentHasLength(ICollection argument, string name, string message)
 {
     if (!ArrayUtils.HasLength(argument))
     {
         throw new ArgumentNullException(name, message);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Checks the value of the supplied <see cref="ICollection"/> <paramref name="argument"/> and throws
 /// an <see cref="ArgumentNullException"/> if it is <see langword="null"/> or contains no elements.
 /// </summary>
 /// <param name="argument">The array or collection to check.</param>
 /// <param name="name">The argument name.</param>
 /// <exception cref="System.ArgumentNullException">
 /// If the supplied <paramref name="argument"/> is <see langword="null"/> or
 /// contains no elements.
 /// </exception>
 public static void ArgumentHasLength(ICollection argument, string name)
 {
     if (!ArrayUtils.HasLength(argument))
     {
         ThrowArgumentNullException(
             name,
             $"Argument '{name}' cannot be null or resolve to an empty array");
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Checks the value of the supplied <see cref="ICollection"/> <paramref name="argument"/> and throws
 /// an <see cref="ArgumentNullException"/> if it is <see langword="null"/> or contains no elements.
 /// </summary>
 /// <param name="argument">The array or collection to check.</param>
 /// <param name="name">The argument name.</param>
 /// <exception cref="System.ArgumentNullException">
 /// If the supplied <paramref name="argument"/> is <see langword="null"/> or
 /// contains no elements.
 /// </exception>
 public static void ArgumentHasLength(ICollection argument, string name)
 {
     if (!ArrayUtils.HasLength(argument))
     {
         throw new ArgumentNullException(
                   name,
                   string.Format(
                       CultureInfo.InvariantCulture,
                       "Argument '{0}' cannot be null or resolve to an empty array", name));
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Checks if the given array or collection is null or has no elements.
 /// </summary>
 /// <param name="collection"></param>
 /// <returns></returns>
 public static bool HasLength(ICollection collection)
 {
     return(ArrayUtils.HasLength(collection));
 }
Exemplo n.º 5
0
 public void HasLengthTests()
 {
     Assert.IsFalse(ArrayUtils.HasLength(null));
     Assert.IsFalse(ArrayUtils.HasLength(new byte[0]));
     Assert.IsTrue(ArrayUtils.HasLength(new byte[1]));
 }