예제 #1
0
        /// <summary>
        /// Ensures that all items in the supplied collection do not consist only of null, empty or whitespace
        /// </summary>
        /// <param name="collection">
        /// The collection to be validated.
        /// </param>
        /// <param name="argumentName">
        /// The argument name.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// If the collection itself is null
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If the collection contains a null value or a string.empty value or only whitespace
        /// </exception>
        public static void AllItemsAreNotNullOrWhitespace(IEnumerable <string> collection, string argumentName, string message)
        {
            Insist.IsNotNull(collection, "collection");

            Insist.AllItemsSatisfyCondition(
                collection,
                (i) => { return(!string.IsNullOrWhiteSpace(i)); },
                argumentName ?? "collection",
                message ?? "A null or string.empty item was found in the collection");
        }
예제 #2
0
        /// <summary>
        /// Ensures that all items in the supplied collection are not null
        /// </summary>
        /// <param name="collection">
        /// The collection to be validated.
        /// </param>
        /// <param name="argumentName">
        /// The argument name.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// If the collection itself is null
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If the collection contains a null value
        /// </exception>
        public static void AllItemsAreNotNull <T>(IEnumerable <T> collection, string argumentName, string message)
        {
            Insist.IsNotNull(collection, "collection");

            Insist.AllItemsSatisfyCondition(
                collection,
                (i) => { return(i != null); },
                argumentName ?? "collection",
                message ?? "A null item was found in the collection");
        }
예제 #3
0
 /// <summary>
 /// Ensures that all items in the supplied collection satisfy the supplied predicate
 /// </summary>
 /// <param name="collection">
 /// The collection to be validated.
 /// </param>
 /// <param name="predicate">
 /// The predicate that is applied to every element in the collection
 /// </param>
 /// <param name="argumentName">
 /// The argument name.
 /// </param>
 /// <exception cref="System.ArgumentNullException">
 /// If the collection itself is null
 /// </exception>
 /// <exception cref="System.ArgumentException">
 /// If the collection contains a value that violates a predicate
 /// </exception>
 public static void AllItemsSatisfyCondition <T>(IEnumerable <T> collection, Predicate <T> predicate, string argumentName)
 {
     Insist.AllItemsSatisfyCondition(collection, predicate, argumentName, null);
 }