mscorlib(4.0.0.0) API with additions
PermissionRequestEvidence.cs
2 
4 {
7  [ComVisible(true)]
8  [Obsolete("Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
9  public sealed class PermissionRequestEvidence : EvidenceBase
10  {
11  private PermissionSet m_request;
12 
13  private PermissionSet m_optional;
14 
15  private PermissionSet m_denied;
16 
17  private string m_strRequest;
18 
19  private string m_strOptional;
20 
21  private string m_strDenied;
22 
25  public PermissionSet RequestedPermissions => m_request;
26 
29  public PermissionSet OptionalPermissions => m_optional;
30 
33  public PermissionSet DeniedPermissions => m_denied;
34 
40  {
41  if (request == null)
42  {
43  m_request = null;
44  }
45  else
46  {
47  m_request = request.Copy();
48  }
49  if (optional == null)
50  {
51  m_optional = null;
52  }
53  else
54  {
55  m_optional = optional.Copy();
56  }
57  if (denied == null)
58  {
59  m_denied = null;
60  }
61  else
62  {
63  m_denied = denied.Copy();
64  }
65  }
66 
69  public override EvidenceBase Clone()
70  {
71  return Copy();
72  }
73 
77  {
78  return new PermissionRequestEvidence(m_request, m_optional, m_denied);
79  }
80 
81  internal SecurityElement ToXml()
82  {
83  SecurityElement securityElement = new SecurityElement("System.Security.Policy.PermissionRequestEvidence");
84  securityElement.AddAttribute("version", "1");
85  if (m_request != null)
86  {
87  SecurityElement securityElement2 = new SecurityElement("Request");
88  securityElement2.AddChild(m_request.ToXml());
89  securityElement.AddChild(securityElement2);
90  }
91  if (m_optional != null)
92  {
93  SecurityElement securityElement2 = new SecurityElement("Optional");
94  securityElement2.AddChild(m_optional.ToXml());
95  securityElement.AddChild(securityElement2);
96  }
97  if (m_denied != null)
98  {
99  SecurityElement securityElement2 = new SecurityElement("Denied");
100  securityElement2.AddChild(m_denied.ToXml());
101  securityElement.AddChild(securityElement2);
102  }
103  return securityElement;
104  }
105 
108  public override string ToString()
109  {
110  return ToXml().ToString();
111  }
112  }
113 }
PermissionSet DeniedPermissions
Gets the permissions the code explicitly asks not to be granted.
Definition: __Canon.cs:3
Provides a base class from which all objects to be used as evidence must derive.
Definition: EvidenceBase.cs:12
void AddChild(SecurityElement child)
Adds a child element to the XML element.
PermissionRequestEvidence Copy()
Creates an equivalent copy of the current T:System.Security.Policy.PermissionRequestEvidence.
Represents a collection that can contain many different types of permissions.
Represents the XML object model for encoding security objects. This class cannot be inherited.
PermissionSet OptionalPermissions
Gets the permissions the code can use if they are granted, but are not required.
override EvidenceBase Clone()
Creates a new object that is a copy of the current instance.
PermissionRequestEvidence(PermissionSet request, PermissionSet optional, PermissionSet denied)
Initializes a new instance of the T:System.Security.Policy.PermissionRequestEvidence class with the p...
void AddAttribute(string name, string value)
Adds a name/value attribute to an XML element.
Specifies that the class can be serialized.
override string ToString()
Gets a string representation of the state of the T:System.Security.Policy.PermissionRequestEvidence.
virtual PermissionSet Copy()
Creates a copy of the T:System.Security.PermissionSet.
PermissionSet RequestedPermissions
Gets the minimum permissions the code requires to run.
Defines evidence that represents permission requests. This class cannot be inherited.
override string ToString()
Produces a string representation of an XML element and its constituent attributes,...