mscorlib(4.0.0.0) API with additions
UnionCodeGroup.cs
1 using System.Collections;
3 
5 {
8  [ComVisible(true)]
9  [Obsolete("This type is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
10  public sealed class UnionCodeGroup : CodeGroup, IUnionSemanticCodeGroup
11  {
14  public override string MergeLogic => Environment.GetResourceString("MergeLogic_Union");
15 
16  internal UnionCodeGroup()
17  {
18  }
19 
20  internal UnionCodeGroup(IMembershipCondition membershipCondition, PermissionSet permSet)
21  : base(membershipCondition, permSet)
22  {
23  }
24 
29  public UnionCodeGroup(IMembershipCondition membershipCondition, PolicyStatement policy)
30  : base(membershipCondition, policy)
31  {
32  }
33 
39  [SecuritySafeCritical]
40  public override PolicyStatement Resolve(Evidence evidence)
41  {
42  if (evidence == null)
43  {
44  throw new ArgumentNullException("evidence");
45  }
46  object usedEvidence = null;
47  if (PolicyManager.CheckMembershipCondition(base.MembershipCondition, evidence, out usedEvidence))
48  {
49  PolicyStatement policyStatement = base.PolicyStatement;
50  IDelayEvaluatedEvidence delayEvaluatedEvidence = usedEvidence as IDelayEvaluatedEvidence;
51  if (delayEvaluatedEvidence != null && !delayEvaluatedEvidence.IsVerified)
52  {
53  policyStatement.AddDependentEvidence(delayEvaluatedEvidence);
54  }
55  bool flag = false;
56  IEnumerator enumerator = base.Children.GetEnumerator();
57  while (enumerator.MoveNext() && !flag)
58  {
59  PolicyStatement policyStatement2 = PolicyManager.ResolveCodeGroup(enumerator.Current as CodeGroup, evidence);
60  if (policyStatement2 != null)
61  {
62  policyStatement.InplaceUnion(policyStatement2);
63  if ((policyStatement2.Attributes & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive)
64  {
65  flag = true;
66  }
67  }
68  }
69  return policyStatement;
70  }
71  return null;
72  }
73 
74  PolicyStatement IUnionSemanticCodeGroup.InternalResolve(Evidence evidence)
75  {
76  if (evidence == null)
77  {
78  throw new ArgumentNullException("evidence");
79  }
80  if (base.MembershipCondition.Check(evidence))
81  {
82  return base.PolicyStatement;
83  }
84  return null;
85  }
86 
91  public override CodeGroup ResolveMatchingCodeGroups(Evidence evidence)
92  {
93  if (evidence == null)
94  {
95  throw new ArgumentNullException("evidence");
96  }
97  if (base.MembershipCondition.Check(evidence))
98  {
99  CodeGroup codeGroup = Copy();
100  codeGroup.Children = new ArrayList();
101  IEnumerator enumerator = base.Children.GetEnumerator();
102  while (enumerator.MoveNext())
103  {
104  CodeGroup codeGroup2 = ((CodeGroup)enumerator.Current).ResolveMatchingCodeGroups(evidence);
105  if (codeGroup2 != null)
106  {
107  codeGroup.AddChild(codeGroup2);
108  }
109  }
110  return codeGroup;
111  }
112  return null;
113  }
114 
117  public override CodeGroup Copy()
118  {
119  UnionCodeGroup unionCodeGroup = new UnionCodeGroup();
120  unionCodeGroup.MembershipCondition = base.MembershipCondition;
121  unionCodeGroup.PolicyStatement = base.PolicyStatement;
122  unionCodeGroup.Name = base.Name;
123  unionCodeGroup.Description = base.Description;
124  IEnumerator enumerator = base.Children.GetEnumerator();
125  while (enumerator.MoveNext())
126  {
127  unionCodeGroup.AddChild((CodeGroup)enumerator.Current);
128  }
129  return unionCodeGroup;
130  }
131 
132  internal override string GetTypeName()
133  {
134  return "System.Security.Policy.UnionCodeGroup";
135  }
136  }
137 }
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.
UnionCodeGroup(IMembershipCondition membershipCondition, PolicyStatement policy)
Initializes a new instance of the T:System.Security.Policy.UnionCodeGroup class.
Definition: __Canon.cs:3
PolicyStatementAttribute
Defines special attribute flags for security policy on code groups.
string Name
Gets or sets the name of the code group.
Definition: CodeGroup.cs:128
IMembershipCondition MembershipCondition
Gets or sets the code group's membership condition.
Definition: CodeGroup.cs:76
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.
Definition: CodeGroup.cs:240
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
IList Children
Gets or sets an ordered list of the child code groups of a code group.
Definition: CodeGroup.cs:32
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.
string Description
Gets or sets the description of the code group.
Definition: CodeGroup.cs:142
object Current
Gets the element in the collection at the current position of the enumerator.
Definition: IEnumerator.cs:15
Represents the abstract base class from which all implementations of code groups must derive.
Definition: CodeGroup.cs:11
PolicyStatement PolicyStatement
Gets or sets the policy statement associated with the code group.
Definition: CodeGroup.cs:99
Defines the set of information that constitutes input to security policy decisions....
Definition: Evidence.cs:17
override PolicyStatement Resolve(Evidence evidence)
Resolves policy for the code group and its descendants for a set of evidence.
Specifies that the class can be serialized.
override CodeGroup ResolveMatchingCodeGroups(Evidence evidence)
Resolves matching code groups.
Represents a code group whose policy statement is the union of the current code group's policy statem...
PolicyStatementAttribute Attributes
Gets or sets the attributes of the policy statement.
Supports a simple iteration over a non-generic collection.
Definition: IEnumerator.cs:9
override string MergeLogic
Gets the merge logic.
override CodeGroup Copy()
Makes a deep copy of the current code group.
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
Definition: ArrayList.cs:14