using System; using System.Collections; namespace Sleis.Utility { public class ArgumentValidationUtility { public static void ThrowOnNull(object obj, string message, object defaultValue) { ThrowOnNull(obj, message); if (obj.Equals(defaultValue)) { throw new ArgumentNullException(message); } } public static void ThrowOnNotNull(object obj, string message) { if (obj != null) { throw new ArgumentNullException(message); } } public static void ThrowOnNull(object obj, string message) { if (obj == null) { throw new ArgumentNullException(message); } } public static void ThrowOnDefault(int val, string message) { if (val == 0) { throw new ArgumentNullException(message); } } public static void ThrowOnEmpty(string val, string message) { if (String.IsNullOrEmpty(val)) { throw new ArgumentNullException(message); } } public static void ThrowOnEmpty(IEnumerable obj, string message) { ThrowOnNull(obj, message); ICollection col = obj as ICollection; if (col != null && col.Count < 1) { throw new ArgumentNullException(message); } } } }