csharp/71/Cometary/src/Cometary.Core/Internal/Requires.cs

Requires.cs
using System;
using System.Collections.Generic;
using System.Linq;

namespace Cometary
{
    internal static clast Requires
    {
        internal static void NotNull(object value, string paramName)
        {
            if (value == null)
                throw new ArgumentNullException(paramName);
        }

        internal static void NoneNull(IEnumerable values, string paramName) where T : clast
        {
            NotNull(values, paramName);

            if (values.Contains(null))
                throw new ArgumentException("The given collection should not contain a null reference.", paramName);
        }

        internal static void NoneNull(IReadOnlyList values, string paramName) where T : clast
        {
            NotNull(values, paramName);

            for (int i = 0; i < values.Count; i++)
            {
                if (ReferenceEquals(values[i], null))
                    throw new ArgumentException("The given collection should not contain a null reference.", paramName);
            }
        }

        internal static void NoneNull(T[] values, string paramName) where T : clast
        {
            NotNull(values, paramName);

            if (Array.IndexOf(values, null) != -1)
                throw new ArgumentException("The given collection should not contain a null reference.", paramName);
        }
    }
}