Not with the enumeration, but with the strings - voila (forcibly executed at runtime, even in full trust):
public static class PermissionFlags {
public const string Create = "Create";
}
[PrincipalPermission(SecurityAction.Demand, Role = PermissionFlags.Create)]
public void CreateNew() {
System.Windows.Forms.MessageBox.Show("Created!");
}
, , . ASP.NET, winform ( VS2008 ..) ASP.NET . winilla winforms WCF; , GenericPrincipal/GenericIdentity:
string[] roles = { PermissionFlags.Create };
Thread.CurrentPrincipal = new GenericPrincipal(
new GenericIdentity("Fred"),
roles);
/ (, / ).