/// <include file='doc\FirstMatchCodeGroup.uex' path='docs/doc[@for="FirstMatchCodeGroup.Resolve"]/*' /> public override PolicyStatement Resolve( Evidence evidence ) { if (evidence == null) throw new ArgumentNullException("evidence"); if (this.MembershipCondition.Check( evidence )) { PolicyStatement childPolicy = null; IEnumerator enumerator = this.Children.GetEnumerator(); while (enumerator.MoveNext()) { childPolicy = ((CodeGroup)enumerator.Current).Resolve( evidence ); // If the child has a policy, we are done. if (childPolicy != null) break; } PolicyStatement thisPolicy = this.PolicyStatement; if (thisPolicy == null) { return childPolicy; } else if (childPolicy != null) { // Combine the child and this policy and return it. PolicyStatement combined = new PolicyStatement(); combined.SetPermissionSetNoCopy( thisPolicy.GetPermissionSetNoCopy().Union( childPolicy.GetPermissionSetNoCopy() ) ); // if both this group and matching child group are exclusive we need to throw an exception if (((thisPolicy.Attributes & childPolicy.Attributes) & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive) throw new PolicyException( Environment.GetResourceString( "Policy_MultipleExclusive" ) ); combined.Attributes = thisPolicy.Attributes | childPolicy.Attributes; return combined; } else { // Otherwise we just copy the this policy. return this.PolicyStatement; } } else { return null; } }
internal CodeGroup(IMembershipCondition membershipCondition, PermissionSet permSet) { Contract.Assert(membershipCondition != null, "membershipCondition != null"); Contract.Assert(permSet != null, "permSet != null"); m_membershipCondition = membershipCondition; m_policy = new PolicyStatement(); m_policy.SetPermissionSetNoCopy(permSet); m_children = ArrayList.Synchronized(new ArrayList()); m_element = null; m_parentLevel = null; }
internal CodeGroup( IMembershipCondition membershipCondition, PermissionSet permSet ) { BCLDebug.Assert( membershipCondition != null, "membershipCondition != null" ); BCLDebug.Assert( permSet != null, "permSet != null" ); m_membershipCondition = membershipCondition; m_policy = new PolicyStatement(); m_policy.SetPermissionSetNoCopy( permSet ); m_children = ArrayList.Synchronized( new ArrayList() ); m_element = null; m_parentLevel = null; }
/// <include file='doc\FirstMatchCodeGroup.uex' path='docs/doc[@for="FirstMatchCodeGroup.Resolve"]/*' /> public override PolicyStatement Resolve(Evidence evidence) { if (evidence == null) { throw new ArgumentNullException("evidence"); } if (this.MembershipCondition.Check(evidence)) { PolicyStatement childPolicy = null; IEnumerator enumerator = this.Children.GetEnumerator(); while (enumerator.MoveNext()) { childPolicy = ((CodeGroup)enumerator.Current).Resolve(evidence); // If the child has a policy, we are done. if (childPolicy != null) { break; } } PolicyStatement thisPolicy = this.PolicyStatement; if (thisPolicy == null) { return(childPolicy); } else if (childPolicy != null) { // Combine the child and this policy and return it. PolicyStatement combined = new PolicyStatement(); combined.SetPermissionSetNoCopy(thisPolicy.GetPermissionSetNoCopy().Union(childPolicy.GetPermissionSetNoCopy())); // if both this group and matching child group are exclusive we need to throw an exception if (((thisPolicy.Attributes & childPolicy.Attributes) & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive) { throw new PolicyException(Environment.GetResourceString("Policy_MultipleExclusive")); } combined.Attributes = thisPolicy.Attributes | childPolicy.Attributes; return(combined); } else { // Otherwise we just copy the this policy. return(this.PolicyStatement); } } else { return(null); } }