Last active
December 18, 2023 13:39
-
-
Save zhangr4/b7b602e6be7a487a73635462a62a55e3 to your computer and use it in GitHub Desktop.
guard usage
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
// refer to https://github.com/ardalis/GuardClauses/tree/main | |
public interface IGuardClause { } | |
public class Guard : IGuardClause | |
{ | |
private Guard() { } | |
public static IGuardClause Against { get; } = new Guard(); | |
} | |
public static class GuardClauseExtensions | |
{ | |
public static T Null<T>(this IGuardClause guardClause, T input, string parameterName) | |
{ | |
if (input is null) | |
throw new ArgumentNullException(parameterName); | |
return input; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment