using System; using System.Collections; using System.Runtime.InteropServices; namespace System.Security.Policy { /// Determines whether an assembly belongs to a code group by testing its zone of origin. This class cannot be inherited. // Token: 0x020005A8 RID: 1448 [ComVisible(true)] [Serializable] public sealed class ZoneMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable { // Token: 0x06003508 RID: 13576 RVA: 0x000B6BC0 File Offset: 0x000B4DC0 internal ZoneMembershipCondition() { } /// Initializes a new instance of the class with the zone that determines membership. /// The for which to test. /// The parameter is not a valid . // Token: 0x06003509 RID: 13577 RVA: 0x000B6BD0 File Offset: 0x000B4DD0 public ZoneMembershipCondition(SecurityZone zone) { this.SecurityZone = zone; } /// Gets or sets the zone for which the membership condition tests. /// The zone for which the membership condition tests. /// The value is null. /// An attempt is made to set to an invalid . // Token: 0x17000A65 RID: 2661 // (get) Token: 0x0600350A RID: 13578 RVA: 0x000B6BE8 File Offset: 0x000B4DE8 // (set) Token: 0x0600350B RID: 13579 RVA: 0x000B6BF0 File Offset: 0x000B4DF0 public SecurityZone SecurityZone { get { return this.zone; } set { if (!Enum.IsDefined(typeof(SecurityZone), value)) { throw new ArgumentException(Locale.GetText("invalid zone")); } if (value == SecurityZone.NoZone) { throw new ArgumentException(Locale.GetText("NoZone isn't valid for membership condition")); } this.zone = value; } } /// Determines whether the specified evidence satisfies the membership condition. /// true if the specified evidence satisfies the membership condition; otherwise, false. /// The evidence set against which to make the test. /// The property is null. /// The property is not a valid . // Token: 0x0600350C RID: 13580 RVA: 0x000B6C48 File Offset: 0x000B4E48 public bool Check(Evidence evidence) { if (evidence == null) { return false; } IEnumerator hostEnumerator = evidence.GetHostEnumerator(); while (hostEnumerator.MoveNext()) { object obj = hostEnumerator.Current; Zone zone = obj as Zone; if (zone != null && zone.SecurityZone == this.zone) { return true; } } return false; } /// Creates an equivalent copy of the membership condition. /// A new, identical copy of the current membership condition. /// The property is null. /// The property is not a valid . // Token: 0x0600350D RID: 13581 RVA: 0x000B6C9C File Offset: 0x000B4E9C public IMembershipCondition Copy() { return new ZoneMembershipCondition(this.zone); } /// Determines whether the zone from the specified object is equivalent to the zone contained in the current . /// true if the zone from the specified object is equivalent to the zone contained in the current ; otherwise, false. /// The object to compare to the current . /// The property for the current object or the specified object is null. /// The property for the current object or the specified object is not a valid . // Token: 0x0600350E RID: 13582 RVA: 0x000B6CAC File Offset: 0x000B4EAC public override bool Equals(object o) { ZoneMembershipCondition zoneMembershipCondition = o as ZoneMembershipCondition; return zoneMembershipCondition != null && zoneMembershipCondition.SecurityZone == this.zone; } /// Reconstructs a security object with a specified state from an XML encoding. /// The XML encoding to use to reconstruct the security object. /// The parameter is null. /// The parameter is not a valid membership condition element. // Token: 0x0600350F RID: 13583 RVA: 0x000B6CD8 File Offset: 0x000B4ED8 public void FromXml(SecurityElement e) { this.FromXml(e, null); } /// Reconstructs a security object with a specified state from an XML encoding. /// The XML encoding to use to reconstruct the security object. /// The policy level context used to resolve named permission set references. /// The parameter is null. /// The parameter is not a valid membership condition element. // Token: 0x06003510 RID: 13584 RVA: 0x000B6CE4 File Offset: 0x000B4EE4 public void FromXml(SecurityElement e, PolicyLevel level) { MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version); string text = e.Attribute("Zone"); if (text != null) { this.zone = (SecurityZone)((int)Enum.Parse(typeof(SecurityZone), text)); } } /// Gets the hash code for the current membership condition. /// The hash code for the current membership condition. /// The property is null. /// The property is not a valid . // Token: 0x06003511 RID: 13585 RVA: 0x000B6D38 File Offset: 0x000B4F38 public override int GetHashCode() { return this.zone.GetHashCode(); } /// Creates and returns a string representation of the membership condition. /// A string representation of the state of the membership condition. /// The property is null. /// The property is not a valid . // Token: 0x06003512 RID: 13586 RVA: 0x000B6D4C File Offset: 0x000B4F4C public override string ToString() { return "Zone - " + this.zone; } /// Creates an XML encoding of the security object and its current state. /// An XML encoding of the security object, including any state information. /// The property is null. /// The property is not a valid . // Token: 0x06003513 RID: 13587 RVA: 0x000B6D64 File Offset: 0x000B4F64 public SecurityElement ToXml() { return this.ToXml(null); } /// Creates an XML encoding of the security object and its current state with the specified . /// An XML encoding of the security object, including any state information. /// The policy level context for resolving named permission set references. /// The property is null. /// The property is not a valid . // Token: 0x06003514 RID: 13588 RVA: 0x000B6D70 File Offset: 0x000B4F70 public SecurityElement ToXml(PolicyLevel level) { SecurityElement securityElement = MembershipConditionHelper.Element(typeof(ZoneMembershipCondition), this.version); securityElement.AddAttribute("Zone", this.zone.ToString()); return securityElement; } // Token: 0x0400158C RID: 5516 private readonly int version = 1; // Token: 0x0400158D RID: 5517 private SecurityZone zone; } }