I’m still poking around the common validation areas of Enterprise Library.
The ArgumentValidation class has 6 public static methods:
public static void CheckForEmptyString(string variable, string variableName) ...
public static void CheckForNullReference(object variable, string variableName) ...
public static void CheckForInvalidNullNameReference(string name, string) ...
public static void CheckForZeroBytes(byte[] bytes, string variableName) ...
public static void CheckExpectedType(object variable, Type type) ...
public static void CheckEnumeration(Type enumType, object variable, string) ...
CheckForEmpty string has the following implementation:
21 public static void CheckForEmptyString(string variable, string variableName)
22 {
23 CheckForNullReference(variable, variableName);
24 CheckForNullReference(variableName, "variableName");
25 if (variable.Length == 0)
26 {
27 throw new ArgumentException(SR.ExceptionEmptyString(variableName));
28 }
29 }
I like this approach to validation. It feels much cleaner to...