15 private IList m_children;
23 private string m_name;
25 private string m_description;
33 [SecuritySafeCritical]
36 if (m_children ==
null)
62 if (codeGroup ==
null)
66 arrayList.
Add(codeGroup.
Copy());
68 m_children = arrayList;
77 [SecuritySafeCritical]
80 if (m_membershipCondition ==
null && m_element !=
null)
82 ParseMembershipCondition();
84 return m_membershipCondition.
Copy();
92 m_membershipCondition = value.Copy();
102 if (m_policy ==
null && m_element !=
null)
106 if (m_policy !=
null)
108 return m_policy.
Copy();
116 m_policy = value.Copy();
145 return m_description;
149 m_description = value;
159 if (m_policy ==
null && m_element !=
null)
163 if (m_policy ==
null)
177 if (m_policy ==
null && m_element !=
null)
181 if (m_policy !=
null)
200 internal CodeGroup(IMembershipCondition membershipCondition,
PermissionSet permSet)
202 m_membershipCondition = membershipCondition;
204 m_policy.SetPermissionSetNoCopy(permSet);
207 m_parentLevel =
null;
217 if (membershipCondition ==
null)
227 m_policy = policy.
Copy();
229 m_membershipCondition = membershipCondition.
Copy();
232 m_parentLevel =
null;
239 [SecuritySafeCritical]
246 if (m_children ==
null)
257 internal void AddChildInternal(
CodeGroup group)
263 if (m_children ==
null)
269 m_children.
Add(group);
276 [SecuritySafeCritical]
281 if (m_children ==
null)
287 int num = m_children.
IndexOf(group);
297 internal IList GetChildrenInternal()
299 if (m_children ==
null)
318 public abstract CodeGroup
Copy();
338 [SecuritySafeCritical]
341 return ToXml(level, GetTypeName());
344 internal virtual string GetTypeName()
346 return GetType().FullName;
352 if (m_membershipCondition ==
null && m_element !=
null)
354 ParseMembershipCondition();
356 if (m_children ==
null)
360 if (m_policy ==
null && m_element !=
null)
364 SecurityElement securityElement =
new SecurityElement(
"CodeGroup");
365 XMLUtil.AddClassAttribute(securityElement, GetType(), policyClassName);
366 securityElement.AddAttribute(
"version",
"1");
367 securityElement.AddChild(m_membershipCondition.
ToXml(level));
368 if (m_policy !=
null)
370 PermissionSet permissionSetNoCopy = m_policy.GetPermissionSetNoCopy();
371 NamedPermissionSet namedPermissionSet = permissionSetNoCopy as NamedPermissionSet;
372 if (namedPermissionSet !=
null && level !=
null && level.GetNamedPermissionSetInternal(namedPermissionSet.Name) !=
null)
374 securityElement.AddAttribute(
"PermissionSetName", namedPermissionSet.Name);
376 else if (!permissionSetNoCopy.IsEmpty())
378 securityElement.AddChild(permissionSetNoCopy.ToXml());
385 if (m_children.
Count > 0)
392 securityElement.AddChild(((CodeGroup)enumerator.
Current).ToXml(level));
398 securityElement.AddAttribute(
"Name", SecurityElement.Escape(m_name));
400 if (m_description !=
null)
402 securityElement.AddAttribute(
"Description", SecurityElement.Escape(m_description));
405 return securityElement;
428 m_parentLevel = level;
430 m_membershipCondition =
null;
432 m_name = e.Attribute(
"Name");
433 m_description = e.Attribute(
"Description");
446 private bool ParseMembershipCondition(
bool safeLoad)
452 if (securityElement ==
null)
458 membershipCondition = XMLUtil.CreateMembershipCondition(securityElement);
459 if (membershipCondition ==
null)
464 catch (Exception innerException)
466 throw new ArgumentException(Environment.GetResourceString(
"Argument_MembershipConditionElement"), innerException);
468 membershipCondition.
FromXml(securityElement, m_parentLevel);
469 m_membershipCondition = membershipCondition;
475 private void ParseMembershipCondition()
477 ParseMembershipCondition(safeLoad:
false);
481 internal void ParseChildren()
486 if (m_element !=
null && m_element.InternalChildren !=
null)
490 Evidence evidence =
new Evidence();
491 int count = m_element.InternalChildren.
Count;
495 SecurityElement securityElement = (SecurityElement)m_element.
Children[num];
496 if (securityElement.Tag.Equals(
"CodeGroup"))
498 CodeGroup codeGroup = XMLUtil.CreateCodeGroup(securityElement);
499 if (codeGroup !=
null)
501 codeGroup.FromXml(securityElement, m_parentLevel);
502 if (ParseMembershipCondition(safeLoad:
true))
504 codeGroup.Resolve(evidence);
505 codeGroup.MembershipCondition.Check(evidence);
506 arrayList.
Add(codeGroup);
511 m_element.InternalChildren.
RemoveAt(num);
512 count = m_element.InternalChildren.
Count;
513 arrayList2.
Add(
new CodeGroupPositionMarker(num, arrayList.
Count, securityElement));
518 m_element.InternalChildren.
RemoveAt(num);
519 count = m_element.InternalChildren.
Count;
520 arrayList2.
Add(
new CodeGroupPositionMarker(num, arrayList.
Count, securityElement));
531 CodeGroupPositionMarker codeGroupPositionMarker = (CodeGroupPositionMarker)enumerator.
Current;
532 CodeGroup codeGroup2 = XMLUtil.CreateCodeGroup(codeGroupPositionMarker.element);
533 if (codeGroup2 ==
null)
535 throw new ArgumentException(
string.Format(
CultureInfo.
CurrentCulture, Environment.GetResourceString(
"Argument_FailedCodeGroup"), codeGroupPositionMarker.element.Attribute(
"class")));
537 codeGroup2.FromXml(codeGroupPositionMarker.element, m_parentLevel);
538 codeGroup2.Resolve(evidence);
539 codeGroup2.MembershipCondition.Check(evidence);
540 arrayList.
Insert(codeGroupPositionMarker.groupIndex, codeGroup2);
541 m_element.InternalChildren.
Insert(codeGroupPositionMarker.elementIndex, codeGroupPositionMarker.element);
544 m_children = arrayList;
548 private void ParsePolicy()
554 SecurityElement securityElement =
new SecurityElement(
"PolicyStatement");
555 securityElement.AddAttribute(
"version",
"1");
556 SecurityElement element = m_element;
559 if (m_element !=
null)
561 string text = m_element.Attribute(
"PermissionSetName");
564 securityElement.AddAttribute(
"PermissionSetName", text);
570 if (securityElement2 !=
null)
572 securityElement.
AddChild(securityElement2);
577 securityElement.AddChild(
new PermissionSet(fUnrestricted:
false).
ToXml());
581 string text2 = m_element.Attribute(
"Attributes");
584 securityElement.AddAttribute(
"Attributes", text2);
591 policyStatement.FromXml(securityElement, m_parentLevel);
595 policyStatement.PermissionSet =
null;
599 if (element == m_element && m_policy ==
null)
601 m_policy = policyStatement;
603 else if (m_policy ==
null)
610 if (m_policy !=
null && m_children !=
null)
612 IMembershipCondition membershipCondition = m_membershipCondition;
620 [SecuritySafeCritical]
624 if (codeGroup !=
null && GetType().
Equals(codeGroup.GetType()) &&
object.
Equals(m_name, codeGroup.m_name) &&
object.Equals(m_description, codeGroup.m_description))
626 if (m_membershipCondition ==
null && m_element !=
null)
628 ParseMembershipCondition();
630 if (codeGroup.m_membershipCondition ==
null && codeGroup.m_element !=
null)
632 codeGroup.ParseMembershipCondition();
634 if (
object.
Equals(m_membershipCondition, codeGroup.m_membershipCondition))
648 [SecuritySafeCritical]
657 if (m_children ==
null)
661 if (cg.m_children ==
null)
671 for (
int i = 0; i < arrayList.
Count; i++)
684 [SecuritySafeCritical]
687 if (m_membershipCondition ==
null && m_element !=
null)
689 ParseMembershipCondition();
691 if (m_name !=
null || m_membershipCondition !=
null)
693 return ((m_name !=
null) ? m_name.GetHashCode() : 0) + ((m_membershipCondition !=
null) ? m_membershipCondition.GetHashCode() : 0);
695 return GetType().GetHashCode();
abstract CodeGroup ResolveMatchingCodeGroups(Evidence evidence)
When overridden in a derived class, resolves matching code groups.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
bool MoveNext()
Advances the enumerator to the next element of the collection.
bool Equals(CodeGroup cg, bool compareChildren)
Determines whether the specified code group is equivalent to the current code group,...
IMembershipCondition Copy()
Creates an equivalent copy of the membership condition.
virtual void Insert(int index, object value)
Inserts an element into the T:System.Collections.ArrayList at the specified index.
virtual void ParseXml(SecurityElement e, PolicyLevel level)
When overridden in a derived class, reconstructs properties and internal state specific to a derived ...
PolicyStatement Copy()
Creates an equivalent copy of the current policy statement.
virtual void RemoveAt(int index)
Removes the element at the specified index of the T:System.Collections.ArrayList.
Represents a non-generic collection of objects that can be individually accessed by index.
static IList Synchronized(IList list)
Returns an T:System.Collections.IList wrapper that is synchronized (thread safe).
Represents the security policy levels for the common language runtime. This class cannot be inherited...
void RemoveAt(int index)
Removes the T:System.Collections.IList item at the specified index.
abstract CodeGroup Copy()
When overridden in a derived class, makes a deep copy of the current code group.
void FromXml(SecurityElement e)
Reconstructs a security object with a given state from an XML encoding.
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.
string Name
Gets or sets the name of the code group.
IMembershipCondition MembershipCondition
Gets or sets the code group's membership condition.
SecurityElement SearchForChildByTag(string tag)
Finds a child by its tag name.
virtual void CreateXml(SecurityElement element, PolicyLevel level)
When overridden in a derived class, serializes properties and internal state specific to a derived co...
int IndexOf(object value)
Determines the index of a specific item in the T:System.Collections.IList.
virtual object Clone()
Creates a shallow copy of the T:System.Collections.ArrayList.
void FromXml(SecurityElement e)
Reconstructs a security object with a specified state from an XML encoding.
Represents the statement of a T:System.Security.Policy.CodeGroup describing the permissions and other...
void AddChild(CodeGroup group)
Adds a child code group to the current code group.
CodeGroup(IMembershipCondition membershipCondition, PolicyStatement policy)
Initializes a new instance of T:System.Security.Policy.CodeGroup.
Defines a permission set that has a name and description associated with it. This class cannot be inh...
abstract string MergeLogic
When overridden in a derived class, gets the merge logic for the code group.
void AddChild(SecurityElement child)
Adds a child element to the XML element.
SecurityElement ToXml()
Creates an XML encoding of the security object and its current state.
Provides information about, and means to manipulate, the current environment and platform....
IList Children
Gets or sets an ordered list of the child code groups of a code group.
Represents a collection that can contain many different types of permissions.
Defines the test to determine whether a code assembly is a member of a code group.
Represents the XML object model for encoding security objects. This class cannot be inherited.
string Description
Gets or sets the description of the code group.
object Current
Gets the element in the collection at the current position of the enumerator.
Represents the abstract base class from which all implementations of code groups must derive.
string AttributeString
Gets a string representation of the attributes of the policy statement.
PolicyStatement PolicyStatement
Gets or sets the policy statement associated with the code group.
int Add(object value)
Adds an item to the T:System.Collections.IList.
SecurityElement ToXml()
Creates an XML encoding of the security object and its current state.
IEnumerator GetEnumerator()
Returns an enumerator that iterates through a collection.
virtual int Add(object value)
Adds an object to the end of the T:System.Collections.ArrayList.
void RemoveChild(CodeGroup group)
Removes the specified child code group.
virtual string? PermissionSetName
Gets the name of the named permission set for the code group.
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.
virtual string AttributeString
Gets a string representation of the attributes of the policy statement for the code group.
Specifies that the class can be serialized.
ArrayList Children
Gets or sets the array of child elements of the XML element.
virtual IEnumerator GetEnumerator()
Returns an enumerator for the entire T:System.Collections.ArrayList.
override int GetHashCode()
Gets the hash code of the current code group.
abstract PolicyStatement Resolve(Evidence evidence)
When overridden in a derived class, resolves policy for the code group and its descendants for a set ...
int Count
Gets the number of elements contained in the T:System.Collections.ICollection.
Provides information about a specific culture (called a locale for unmanaged code development)....
SecurityElement ToXml(PolicyLevel level)
Creates an XML encoding of the security object, its current state, and the policy level within which ...
override bool Equals(object o)
Determines whether the specified code group is equivalent to the current code group.
PolicyStatementAttribute Attributes
Gets or sets the attributes of the policy statement.
void FromXml(SecurityElement e, PolicyLevel level)
Reconstructs a security object with a given state and policy level from an XML encoding.
Supports a simple iteration over a non-generic collection.
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...