コード例 #1
0
        public static void IfCollectionContainsNull <T>(
            [CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)] IEnumerable <T> collection,
            [NotNull] string collectionName) where T : class
        {
            Fail.RequiresCollectionName(collectionName);

            Fail.IfArgumentNull(collection, nameof(collection));
            Fail.IfTrue(collection.Contains(null), "Collection '{0}' contains null", collectionName);
        }
コード例 #2
0
        public static void IfCollectionContains <T>(
            [CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)]
            IEnumerable <T> collection,
            [NotNull][System.Diagnostics.CodeAnalysis.NotNull] Func <T, bool> func,
            Violation message
            )
        {
            Fail.IfArgumentNull(collection, nameof(collection));
            T element = collection.FirstOrDefault(func);

            Fail.IfNotNull(element, message);
        }
コード例 #3
0
        public static void IfArgumentWhiteSpace(
            [CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)] string argumentValue,
            [NotNull][System.Diagnostics.CodeAnalysis.NotNull] string argumentName)
        {
            Fail.RequiresArgumentName(argumentName);
            Fail.IfArgumentNull(argumentValue, argumentName);

            if (string.IsNullOrWhiteSpace(argumentValue))
            {
                throw Fail.Because(Violation.WhenArgumentWhitespace(argumentName));
            }
        }
コード例 #4
0
        public static void IfArgumentEmpty(
            [CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)] string argumentValue,
            [NotNull][System.Diagnostics.CodeAnalysis.NotNull] string argumentName)
        {
            Fail.RequiresArgumentName(argumentName);
            Fail.IfArgumentNull(argumentValue, argumentName);

            if (argumentValue.Length == 0)
            {
                throw Fail.Because(Violation.WhenArgumentEmpty(argumentName));
            }
        }
コード例 #5
0
        public static void IfCollectionContains <T>(
            [CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)] IEnumerable <T> collection,
            [NotNull] Func <T, bool> func,
            [NotNull] string message,
            [NotNull] params object[] args)
        {
            Fail.RequiresMessage(message, args);

            Fail.IfArgumentNull(collection, nameof(collection));
            T element = collection.FirstOrDefault(func);

            Fail.IfNotNull(element, message, args);
        }
コード例 #6
0
        public static void IfArgumentWhiteSpace(
            [CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)] string argumentValue,
            [NotNull] string argumentName)
        {
            Fail.RequiresArgumentName(argumentName);

            Fail.IfArgumentNull(argumentValue, argumentName);

            if (string.IsNullOrWhiteSpace(argumentValue))
            {
                throw Fail.Because("Argument '{0}' was empty.", argumentName);
            }
        }
コード例 #7
0
        public static void IfArgumentEmpty(
            [CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)] string argumentValue,
            [NotNull] string argumentName)
        {
            Fail.RequiresArgumentName(argumentName);

            Fail.IfArgumentNull(argumentValue, argumentName);

            if (argumentValue.Length == 0)
            {
                throw Fail.Because("Argument '{0}' was empty.", argumentName);
            }
        }
コード例 #8
0
 // ReSharper disable once InconsistentNaming
 public static void fian([CanBeNull][NoEnumeration] this object argumentValue)
 {
     Fail.IfArgumentNull(argumentValue, nameof(argumentValue));
 }