Created
December 20, 2020 15:20
-
-
Save Rene-Sackers/a67d35b3b92f66abb56d460dc70f9b1f to your computer and use it in GitHub Desktop.
Strong typed policies
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 class Policy | |
{ | |
public string Name { get; } | |
public Policy(string name) | |
{ | |
Name = name; | |
} | |
public static implicit operator string(Policy policy) => policy.Name; | |
} | |
public static class Policies | |
{ | |
private static Policy CreatePolicy([CallerMemberName] string name = null) => new(name); | |
public static readonly Policy EditComment = CreatePolicy(); | |
public static readonly Policy DeleteCommand = CreatePolicy(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment