public override CodeGroup ResolveMatchingCodeGroups(Evidence evidence) { if (null == evidence) { throw new ArgumentNullException("evidence"); } if (!MembershipCondition.Check(evidence)) { return(null); } FileCodeGroup matchRoot = new FileCodeGroup(MembershipCondition, m_access); foreach (CodeGroup child in Children) { CodeGroup childMatchingCodeGroup = child.ResolveMatchingCodeGroups(evidence); if (childMatchingCodeGroup != null) { matchRoot.AddChild(childMatchingCodeGroup); } } return(matchRoot); }
// Resolve code groups that match specific evidence. public override CodeGroup ResolveMatchingCodeGroups(Evidence evidence) { FileCodeGroup newGroup; CodeGroup child; // Validate the parameter. if (evidence == null) { throw new ArgumentNullException("evidence"); } // Check the membership condition. if (!MembershipCondition.Check(evidence)) { return(null); } // Clone this group, except for the children. newGroup = new FileCodeGroup(MembershipCondition, access); newGroup.Name = Name; newGroup.Description = Description; // Resolve and add the children. foreach (CodeGroup group in Children) { child = group.ResolveMatchingCodeGroups(evidence); if (child != null) { newGroup.AddChild(child); } } // Return the result. return(newGroup); }
public override CodeGroup Copy () { FileCodeGroup copy = new FileCodeGroup (MembershipCondition, m_access); copy.Name = this.Name; copy.Description = this.Description; foreach (CodeGroup child in Children) { copy.AddChild (child.Copy ()); // deep copy } return copy; }
public override CodeGroup Copy() { FileCodeGroup copy = new FileCodeGroup(MembershipCondition, m_access); copy.Name = this.Name; copy.Description = this.Description; foreach (CodeGroup child in Children) { copy.AddChild(child.Copy()); // deep copy } return(copy); }
/// <summary>生成当前代码组的深层副本。</summary> /// <returns>当前代码组(包括其成员条件和子代码组)的等效副本。</returns> public override CodeGroup Copy() { FileCodeGroup fileCodeGroup = new FileCodeGroup(this.MembershipCondition, this.m_access); fileCodeGroup.Name = this.Name; fileCodeGroup.Description = this.Description; foreach (CodeGroup child in (IEnumerable)this.Children) { fileCodeGroup.AddChild(child); } return((CodeGroup)fileCodeGroup); }
/// <summary>Makes a deep copy of the current code group.</summary> /// <returns>An equivalent copy of the current code group, including its membership conditions and child code groups.</returns> // Token: 0x0600293D RID: 10557 RVA: 0x00098400 File Offset: 0x00096600 public override CodeGroup Copy() { FileCodeGroup fileCodeGroup = new FileCodeGroup(base.MembershipCondition, this.m_access); fileCodeGroup.Name = base.Name; fileCodeGroup.Description = base.Description; foreach (object obj in base.Children) { fileCodeGroup.AddChild((CodeGroup)obj); } return(fileCodeGroup); }
public override CodeGroup Copy() { FileCodeGroup group = new FileCodeGroup(base.MembershipCondition, this.m_access) { Name = base.Name, Description = base.Description }; IEnumerator enumerator = base.Children.GetEnumerator(); while (enumerator.MoveNext()) { group.AddChild((CodeGroup) enumerator.Current); } return group; }
public override CodeGroup Copy() { FileCodeGroup group = new FileCodeGroup(this.MembershipCondition, this.m_access); group.Name = this.Name; group.Description = this.Description; IEnumerator enumerator = this.Children.GetEnumerator(); while (enumerator.MoveNext()) { group.AddChild((CodeGroup)enumerator.Current); } return(group); }
// Make a copy of this code group. public override CodeGroup Copy() { FileCodeGroup group; group = new FileCodeGroup(MembershipCondition, access); group.Name = Name; group.Description = Description; IList children = Children; if(children != null) { foreach(CodeGroup child in children) { group.AddChild(child); } } return group; }
// Make a copy of this code group. public override CodeGroup Copy() { FileCodeGroup group; group = new FileCodeGroup(MembershipCondition, access); group.Name = Name; group.Description = Description; IList children = Children; if (children != null) { foreach (CodeGroup child in children) { group.AddChild(child); } } return(group); }
/// <summary>Resolves matching code groups.</summary> /// <returns>A <see cref="T:System.Security.Policy.CodeGroup" /> that is the root of the tree of matching code groups.</returns> /// <param name="evidence">The evidence for the assembly. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="evidence" /> parameter is null. </exception> public override CodeGroup ResolveMatchingCodeGroups(Evidence evidence) { if (evidence == null) { throw new ArgumentNullException("evidence"); } if (!base.MembershipCondition.Check(evidence)) { return(null); } FileCodeGroup fileCodeGroup = new FileCodeGroup(base.MembershipCondition, this.m_access); foreach (object obj in base.Children) { CodeGroup codeGroup = (CodeGroup)obj; CodeGroup codeGroup2 = codeGroup.ResolveMatchingCodeGroups(evidence); if (codeGroup2 != null) { fileCodeGroup.AddChild(codeGroup2); } } return(fileCodeGroup); }
public override CodeGroup ResolveMatchingCodeGroups(Evidence evidence) { if (null == evidence) throw new ArgumentNullException("evidence"); if (!MembershipCondition.Check (evidence)) return null; FileCodeGroup matchRoot = new FileCodeGroup (MembershipCondition, m_access); foreach (CodeGroup child in Children) { CodeGroup childMatchingCodeGroup = child.ResolveMatchingCodeGroups (evidence); if (childMatchingCodeGroup != null) matchRoot.AddChild (childMatchingCodeGroup); } return matchRoot; }
public void ResolveMatchingCodeGroups_ThreeLevel () { FileCodeGroup level1 = new FileCodeGroup (new AllMembershipCondition (), FileIOPermissionAccess.AllAccess); CodeGroup level2 = level1.Copy (); level1.AddChild (level2); FileCodeGroup level3 = new FileCodeGroup (new ZoneMembershipCondition (SecurityZone.Untrusted), FileIOPermissionAccess.AllAccess); level2.AddChild (level3); CodeGroup match = level1.ResolveMatchingCodeGroups (new Evidence ()); Assert.IsNotNull (match, "Match"); Assert.IsTrue (match.Equals (level1, false), "Equals(false)"); // Equals (true) isn't a deep compare (just one level) Assert.IsTrue (match.Equals (level1, true), "Equals(true)"); }
public void ResolveMatchingCodeGroups_TwoLevel () { FileCodeGroup level1 = new FileCodeGroup (new AllMembershipCondition (), FileIOPermissionAccess.AllAccess); CodeGroup level2 = level1.Copy (); level1.AddChild (level2); CodeGroup match = level1.ResolveMatchingCodeGroups (new Evidence ()); Assert.IsNotNull (match, "Match"); Assert.IsTrue (match.Equals (level1, false), "Equals(false)"); Assert.IsTrue (match.Equals (level1, true), "Equals(true)"); FileCodeGroup level2b = new FileCodeGroup (new ZoneMembershipCondition (SecurityZone.Untrusted), FileIOPermissionAccess.AllAccess); level1.AddChild (level2b); CodeGroup match2 = level1.ResolveMatchingCodeGroups (new Evidence ()); Assert.IsNotNull (match2, "Match2"); Assert.IsTrue (match2.Equals (level1, false), "Equals(false)"); Assert.IsTrue (!match2.Equals (level1, true), "Equals(true)"); }
public void CopyWithChildren () { FileCodeGroup cgChild = new FileCodeGroup (new AllMembershipCondition (), FileIOPermissionAccess.AllAccess); FileCodeGroup cg = new FileCodeGroup (new AllMembershipCondition (), FileIOPermissionAccess.AllAccess); cg.AddChild (cgChild); FileCodeGroup cg2 = (FileCodeGroup) cg.Copy (); Assert.AreEqual (cg.Children.Count, cg2.Children.Count, "Children"); Assert.AreEqual (cg.ToXml ().ToString (), cg2.ToXml ().ToString (), "ToXml"); }
// Resolve code groups that match specific evidence. public override CodeGroup ResolveMatchingCodeGroups(Evidence evidence) { FileCodeGroup newGroup; CodeGroup child; // Validate the parameter. if(evidence == null) { throw new ArgumentNullException("evidence"); } // Check the membership condition. if(!MembershipCondition.Check(evidence)) { return null; } // Clone this group, except for the children. newGroup = new FileCodeGroup(MembershipCondition, access); newGroup.Name = Name; newGroup.Description = Description; // Resolve and add the children. foreach(CodeGroup group in Children) { child = group.ResolveMatchingCodeGroups(evidence); if(child != null) { newGroup.AddChild(child); } } // Return the result. return newGroup; }