31 return m_permSet.
Copy();
44 m_permSet = value.Copy();
60 if (ValidProperties(value))
77 stringBuilder.
Append(
"Exclusive");
86 stringBuilder.
Append(
"LevelFinal");
94 internal bool HasDependentEvidence
98 if (m_dependentEvidence !=
null)
100 return m_dependentEvidence.
Count > 0;
106 internal PolicyStatement()
130 m_permSet = permSet.
Copy();
132 if (ValidProperties(attributes))
134 m_attributes = attributes;
144 m_permSet = permSet.
Copy();
155 m_attributes = attributes;
176 if (HasDependentEvidence)
180 return policyStatement;
192 private bool GetFlag(
int flag)
194 return (flag & (
int)m_attributes) != 0;
197 internal void AddDependentEvidence(IDelayEvaluatedEvidence dependentEvidence)
199 if (m_dependentEvidence ==
null)
203 m_dependentEvidence.
Add(dependentEvidence);
206 internal void InplaceUnion(PolicyStatement childPolicy)
210 throw new PolicyException(Environment.GetResourceString(
"Policy_MultipleExclusive"));
212 if (childPolicy.HasDependentEvidence)
214 bool flag = m_permSet.IsSubsetOf(childPolicy.GetPermissionSetNoCopy()) && !childPolicy.GetPermissionSetNoCopy().IsSubsetOf(m_permSet);
215 if (HasDependentEvidence | flag)
217 if (m_dependentEvidence ==
null)
221 m_dependentEvidence.
AddRange(childPolicy.DependentEvidence);
226 m_permSet = childPolicy.GetPermissionSetNoCopy();
231 m_permSet.InplaceUnion(childPolicy.GetPermissionSetNoCopy());
257 return ToXml(level, useInternal:
false);
264 if (m_attributes != 0)
270 if (m_permSet ==
null)
272 return securityElement;
274 if (!(m_permSet is NamedPermissionSet))
278 securityElement.
AddChild(m_permSet.ToXml());
279 return securityElement;
281 securityElement.
AddChild(m_permSet.InternalToXml());
282 return securityElement;
284 NamedPermissionSet namedPermissionSet = (NamedPermissionSet)m_permSet;
287 securityElement.
AddAttribute(
"PermissionSetName", namedPermissionSet.Name);
288 return securityElement;
292 securityElement.
AddChild(namedPermissionSet.ToXml());
293 return securityElement;
295 securityElement.
AddChild(namedPermissionSet.InternalToXml());
296 return securityElement;
305 [SecuritySafeCritical]
308 FromXml(et, level, allowInternalOnly:
false);
318 if (!et.
Tag.Equals(
"PolicyStatement"))
323 string text = et.Attribute(
"Attributes");
333 string text2 = et.Attribute(
"PermissionSetName");
336 m_permSet = level.GetNamedPermissionSetInternal(text2);
337 if (m_permSet ==
null)
343 if (m_permSet ==
null)
346 if (securityElement ==
null)
348 throw new ArgumentException(Environment.GetResourceString(
"Argument_InvalidXML"));
350 string text3 = securityElement.Attribute(
"class");
351 if (text3 !=
null && (text3.Equals(
"NamedPermissionSet") || text3.Equals(
"System.Security.NamedPermissionSet")))
353 m_permSet =
new NamedPermissionSet(
"DefaultName",
PermissionState.None);
361 m_permSet.FromXml(securityElement, allowInternalOnly, ignoreTypeLoadFailures:
true);
367 if (m_permSet ==
null)
375 internal void FromXml(SecurityDocument doc,
int position, PolicyLevel level,
bool allowInternalOnly)
379 throw new ArgumentNullException(
"doc");
381 if (!doc.GetTagForElement(position).Equals(
"PolicyStatement"))
383 throw new ArgumentException(
string.Format(
CultureInfo.
CurrentCulture, Environment.GetResourceString(
"Argument_InvalidXMLElement"),
"PolicyStatement", GetType().FullName));
386 string attributeForElement = doc.GetAttributeForElement(position,
"Attributes");
387 if (attributeForElement !=
null)
396 string attributeForElement2 = doc.GetAttributeForElement(position,
"PermissionSetName");
397 if (attributeForElement2 !=
null)
399 m_permSet = level.GetNamedPermissionSetInternal(attributeForElement2);
400 if (m_permSet ==
null)
406 if (m_permSet ==
null)
408 ArrayList childrenPositionForElement = doc.GetChildrenPositionForElement(position);
410 for (
int i = 0; i < childrenPositionForElement.
Count; i++)
412 if (doc.GetTagForElement((
int)childrenPositionForElement[i]).Equals(
"PermissionSet"))
414 num = (int)childrenPositionForElement[i];
419 throw new ArgumentException(Environment.GetResourceString(
"Argument_InvalidXML"));
421 string attributeForElement3 = doc.GetAttributeForElement(num,
"class");
422 if (attributeForElement3 !=
null && (attributeForElement3.Equals(
"NamedPermissionSet") || attributeForElement3.Equals(
"System.Security.NamedPermissionSet")))
424 m_permSet =
new NamedPermissionSet(
"DefaultName",
PermissionState.None);
430 m_permSet.FromXml(doc, num, allowInternalOnly);
432 if (m_permSet ==
null)
447 if (policyStatement ==
null)
451 if (m_attributes != policyStatement.m_attributes)
455 if (!
object.
Equals(m_permSet, policyStatement.m_permSet))
467 int num = (int)m_attributes;
468 if (m_permSet !=
null)
470 num ^= m_permSet.GetHashCode();
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
int Count
Gets the number of elements contained in the T:System.Collections.Generic.List`1.
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
PolicyStatement Copy()
Creates an equivalent copy of the current policy statement.
PolicyStatement(PermissionSet permSet, PolicyStatementAttribute attributes)
Initializes a new instance of the T:System.Security.Policy.PolicyStatement class with the specified T...
PermissionSet PermissionSet
Gets or sets the T:System.Security.PermissionSet of the policy statement.
ReadOnlyCollection< T > AsReadOnly()
Returns a read-only T:System.Collections.ObjectModel.ReadOnlyCollection`1 wrapper for the current col...
Represents the security policy levels for the common language runtime. This class cannot be inherited...
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
PolicyStatementAttribute
Defines special attribute flags for security policy on code groups.
SecurityElement SearchForChildByTag(string tag)
Finds a child by its tag name.
string Tag
Gets or sets the tag name of an XML element.
PolicyStatement(PermissionSet permSet)
Initializes a new instance of the T:System.Security.Policy.PolicyStatement class with the specified T...
Represents the statement of a T:System.Security.Policy.CodeGroup describing the permissions and other...
static object Parse(Type enumType, string value)
Converts the string representation of the name or numeric value of one or more enumerated constants t...
void AddChild(SecurityElement child)
Adds a child element to the XML element.
void Add(T item)
Adds an object to the end of the T:System.Collections.Generic.List`1.
Provides information about, and means to manipulate, the current environment and platform....
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
Represents a collection that can contain many different types of permissions.
override bool Equals(object obj)
Determines whether the specified T:System.Security.Policy.PolicyStatement object is equal to the curr...
Provides the base class for enumerations.
Represents the XML object model for encoding security objects. This class cannot be inherited.
Defines the methods that convert permission object state to and from XML element representation.
override int GetHashCode()
Gets a hash code for the T:System.Security.Policy.PolicyStatement object that is suitable for use in ...
string AttributeString
Gets a string representation of the attributes of the policy statement.
void AddRange(IEnumerable< T > collection)
Adds the elements of the specified collection to the end of the T:System.Collections....
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
SecurityElement ToXml()
Creates an XML encoding of the security object and its current state.
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
The exception that is thrown when one of the arguments provided to a method is not valid.
Supports the methods that convert permission object state to and from an XML element representation.
Attribute can be applied to an enumeration.
PermissionState
Specifies whether a permission should have all or no access to resources at creation.
void AddAttribute(string name, string value)
Adds a name/value attribute to an XML element.
Specifies that the class can be serialized.
void FromXml(SecurityElement et)
Reconstructs a security object with a given state from an XML encoding.
void FromXml(SecurityElement et, PolicyLevel level)
Reconstructs a security object with a given state from an XML encoding.
virtual PermissionSet Copy()
Creates a copy of the T:System.Security.PermissionSet.
Provides information about a specific culture (called a locale for unmanaged code development)....
NamedPermissionSet GetNamedPermissionSet(string name)
Returns the T:System.Security.NamedPermissionSet in the current policy level with the specified name.
SecurityElement ToXml(PolicyLevel level)
Creates an XML encoding of the security object and its current state.
PolicyStatementAttribute Attributes
Gets or sets the attributes of the policy statement.
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...