Skip to content

Instantly share code, notes, and snippets.

@zhangr4
Last active December 18, 2023 13:39
Show Gist options
  • Save zhangr4/b7b602e6be7a487a73635462a62a55e3 to your computer and use it in GitHub Desktop.
Save zhangr4/b7b602e6be7a487a73635462a62a55e3 to your computer and use it in GitHub Desktop.
guard usage
// 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