using System;
using System.Collections;
using System.Globalization;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// Determines whether an assembly belongs to a code group by testing the site from which it originated. This class cannot be inherited.
// Token: 0x0200059F RID: 1439
[ComVisible(true)]
[Serializable]
public sealed class SiteMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
// Token: 0x060034A3 RID: 13475 RVA: 0x000B59C0 File Offset: 0x000B3BC0
internal SiteMembershipCondition()
{
}
/// Initializes a new instance of the class with name of the site that determines membership.
/// The site name or wildcard expression.
/// The parameter is null.
/// The parameter is not a valid .
// Token: 0x060034A4 RID: 13476 RVA: 0x000B59D0 File Offset: 0x000B3BD0
public SiteMembershipCondition(string site)
{
this.Site = site;
}
/// Gets or sets the site for which the membership condition tests.
/// The site for which the membership condition tests.
/// An attempt is made to set to null.
/// An attempt is made to set to an invalid .
// Token: 0x17000A54 RID: 2644
// (get) Token: 0x060034A5 RID: 13477 RVA: 0x000B59E8 File Offset: 0x000B3BE8
// (set) Token: 0x060034A6 RID: 13478 RVA: 0x000B59F0 File Offset: 0x000B3BF0
public string Site
{
get
{
return this._site;
}
set
{
if (value == null)
{
throw new ArgumentNullException("site");
}
if (!global::System.Security.Policy.Site.IsValid(value))
{
throw new ArgumentException("invalid site");
}
this._site = value;
}
}
/// Determines whether the specified evidence satisfies the membership condition.
/// true if the specified evidence satisfies the membership condition; otherwise, false.
/// The against which to make the test.
/// The property is null.
// Token: 0x060034A7 RID: 13479 RVA: 0x000B5A2C File Offset: 0x000B3C2C
public bool Check(Evidence evidence)
{
if (evidence == null)
{
return false;
}
IEnumerator hostEnumerator = evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
if (hostEnumerator.Current is Site)
{
string[] array = this._site.Split(new char[] { '.' });
string[] array2 = (hostEnumerator.Current as Site).origin_site.Split(new char[] { '.' });
int i = array.Length - 1;
int num = array2.Length - 1;
while (i >= 0)
{
if (i == 0)
{
return string.Compare(array[0], "*", true, CultureInfo.InvariantCulture) == 0;
}
if (string.Compare(array[i], array2[num], true, CultureInfo.InvariantCulture) != 0)
{
return false;
}
i--;
num--;
}
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.
// Token: 0x060034A8 RID: 13480 RVA: 0x000B5AFC File Offset: 0x000B3CFC
public IMembershipCondition Copy()
{
return new SiteMembershipCondition(this._site);
}
/// Determines whether the site from the specified object is equivalent to the site contained in the current .
/// true if the site from the specified object is equivalent to the site 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.
// Token: 0x060034A9 RID: 13481 RVA: 0x000B5B0C File Offset: 0x000B3D0C
public override bool Equals(object o)
{
if (o == null)
{
return false;
}
if (o is SiteMembershipCondition)
{
Site site = new Site((o as SiteMembershipCondition)._site);
return site.Equals(new Site(this._site));
}
return false;
}
/// 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: 0x060034AA RID: 13482 RVA: 0x000B5B50 File Offset: 0x000B3D50
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 context, used to resolve references.
/// The parameter is null.
/// The parameter is not a valid membership condition element.
// Token: 0x060034AB RID: 13483 RVA: 0x000B5B5C File Offset: 0x000B3D5C
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
this._site = e.Attribute("Site");
}
/// Gets the hash code for the current membership condition.
/// The hash code for the current membership condition.
/// The property is null.
///
///
///
// Token: 0x060034AC RID: 13484 RVA: 0x000B5B88 File Offset: 0x000B3D88
public override int GetHashCode()
{
return this._site.GetHashCode();
}
/// Creates and returns a string representation of the membership condition.
/// A string representation of the membership condition.
/// The property is null.
// Token: 0x060034AD RID: 13485 RVA: 0x000B5B98 File Offset: 0x000B3D98
public override string ToString()
{
return "Site - " + this._site;
}
/// 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.
// Token: 0x060034AE RID: 13486 RVA: 0x000B5BAC File Offset: 0x000B3DAC
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 context, used to resolve references.
/// The property is null.
// Token: 0x060034AF RID: 13487 RVA: 0x000B5BB8 File Offset: 0x000B3DB8
public SecurityElement ToXml(PolicyLevel level)
{
SecurityElement securityElement = MembershipConditionHelper.Element(typeof(SiteMembershipCondition), this.version);
securityElement.AddAttribute("Site", this._site);
return securityElement;
}
// Token: 0x04001574 RID: 5492
private readonly int version = 1;
// Token: 0x04001575 RID: 5493
private string _site;
}
}