public static SecurityDeclaration ToSecurityDeclaration(this PermissionSet self, SecurityAction action, ModuleDefinition module)
{
if (self == null)
throw new ArgumentNullException ("self");
if (module == null)
throw new ArgumentNullException ("module");
var declaration = new SecurityDeclaration (action);
var attribute = new SecurityAttribute (
module.TypeSystem.LookupType ("System.Security.Permissions", "PermissionSetAttribute"));
attribute.Properties.Add (
new CustomAttributeNamedArgument (
"XML",
new CustomAttributeArgument (
module.TypeSystem.String, self.ToXml ().ToString ())));
declaration.SecurityAttributes.Add (attribute);
return declaration;
}