Created
February 10, 2018 02:49
-
-
Save loneshark99/8c1a64a16d44bd14cbe371a387628f05 to your computer and use it in GitHub Desktop.
Guard class for Argument Validations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Guard | |
{ | |
public static void NotNull<T>(string argumentName, T value) | |
where T : class | |
{ | |
if (value == null) | |
throw new ArgumentNullException(argumentName); | |
} | |
public static void NotEmpty(string argumentName, string value) | |
{ | |
if (String.IsNullOrWhiteSpace(value)) | |
throw new ArgumentException("Non-empty string expected", argumentName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment