using System;
using System.Collections;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using Mono.Security;
namespace System.Security.Policy
{
/// Determines whether an assembly belongs to a code group by testing its application directory. This class cannot be inherited.
// Token: 0x0200057B RID: 1403
[ComVisible(true)]
[Serializable]
public sealed class ApplicationDirectoryMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
/// Determines whether the membership condition is satisfied by the specified evidence.
/// true if the specified evidence satisfies the membership condition; otherwise, false.
/// The evidence set against which to make the test.
// Token: 0x06003347 RID: 13127 RVA: 0x000B054C File Offset: 0x000AE74C
public bool Check(Evidence evidence)
{
if (evidence == null)
{
return false;
}
string codeBase = Assembly.GetCallingAssembly().CodeBase;
Uri uri = new Uri(codeBase);
Url url = new Url(codeBase);
bool flag = false;
bool flag2 = false;
IEnumerator hostEnumerator = evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
object obj = hostEnumerator.Current;
if (!flag && obj is ApplicationDirectory)
{
ApplicationDirectory applicationDirectory = obj as ApplicationDirectory;
string directory = applicationDirectory.Directory;
flag = string.Compare(directory, 0, uri.ToString(), 0, directory.Length, true, CultureInfo.InvariantCulture) == 0;
}
else if (!flag2 && obj is Url)
{
flag2 = url.Equals(obj);
}
if (flag && flag2)
{
return true;
}
}
return false;
}
/// Creates an equivalent copy of the membership condition.
/// A new, identical copy of the current membership condition.
// Token: 0x06003348 RID: 13128 RVA: 0x000B0618 File Offset: 0x000AE818
public IMembershipCondition Copy()
{
return new ApplicationDirectoryMembershipCondition();
}
/// Determines whether the specified membership condition is an .
/// true if the specified membership condition is an ; otherwise, false.
/// The object to compare to .
// Token: 0x06003349 RID: 13129 RVA: 0x000B0620 File Offset: 0x000AE820
public override bool Equals(object o)
{
return o is ApplicationDirectoryMembershipCondition;
}
/// 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 application directory membership condition element.
// Token: 0x0600334A RID: 13130 RVA: 0x000B062C File Offset: 0x000AE82C
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 application directory membership condition element.
// Token: 0x0600334B RID: 13131 RVA: 0x000B0638 File Offset: 0x000AE838
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
}
/// Gets the hash code for the current membership condition.
/// The hash code for the current membership condition.
// Token: 0x0600334C RID: 13132 RVA: 0x000B0654 File Offset: 0x000AE854
public override int GetHashCode()
{
return typeof(ApplicationDirectoryMembershipCondition).GetHashCode();
}
/// Creates and returns a string representation of the membership condition.
/// A string representation of the state of the membership condition.
// Token: 0x0600334D RID: 13133 RVA: 0x000B0668 File Offset: 0x000AE868
public override string ToString()
{
return "ApplicationDirectory";
}
/// Creates an XML encoding of the security object and its current state.
/// An XML encoding of the security object, including any state information.
// Token: 0x0600334E RID: 13134 RVA: 0x000B0670 File Offset: 0x000AE870
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.
// Token: 0x0600334F RID: 13135 RVA: 0x000B067C File Offset: 0x000AE87C
public SecurityElement ToXml(PolicyLevel level)
{
return MembershipConditionHelper.Element(typeof(ApplicationDirectoryMembershipCondition), this.version);
}
// Token: 0x04001503 RID: 5379
private readonly int version = 1;
}
}