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); }
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); }
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)); } }
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)); } }
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); }
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); } }
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); } }
// ReSharper disable once InconsistentNaming public static void fian([CanBeNull][NoEnumeration] this object argumentValue) { Fail.IfArgumentNull(argumentValue, nameof(argumentValue)); }