Files
2026-06-04 11:42:34 +02:00

113 lines
5.2 KiB
C#

using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Determines whether an assembly belongs to a code group by testing its global assembly cache membership. This class cannot be inherited.</summary>
// Token: 0x0200058C RID: 1420
[ComVisible(true)]
[Serializable]
public sealed class GacMembershipCondition : IConstantMembershipCondition, IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
{
/// <summary>Indicates whether the specified evidence satisfies the membership condition.</summary>
/// <returns>true if the specified evidence satisfies the membership condition; otherwise, false.</returns>
/// <param name="evidence">The <see cref="T:System.Security.Policy.Evidence" /> against which to make the test. </param>
// Token: 0x060033F7 RID: 13303 RVA: 0x000B2C48 File Offset: 0x000B0E48
public bool Check(Evidence evidence)
{
if (evidence == null)
{
return false;
}
IEnumerator hostEnumerator = evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
if (hostEnumerator.Current is GacInstalled)
{
return true;
}
}
return false;
}
/// <summary>Creates an equivalent copy of the membership condition.</summary>
/// <returns>A new <see cref="T:System.Security.Policy.GacMembershipCondition" /> object.</returns>
// Token: 0x060033F8 RID: 13304 RVA: 0x000B2C88 File Offset: 0x000B0E88
public IMembershipCondition Copy()
{
return new GacMembershipCondition();
}
/// <summary>Indicates whether the current object is equivalent to the specified object.</summary>
/// <returns>true if <paramref name="o" /> is a <see cref="T:System.Security.Policy.GacMembershipCondition" />; otherwise, false.</returns>
/// <param name="o">The object to compare with the current object. </param>
// Token: 0x060033F9 RID: 13305 RVA: 0x000B2C90 File Offset: 0x000B0E90
public override bool Equals(object o)
{
return o != null && o is GacMembershipCondition;
}
/// <summary>Uses the specified XML encoding to reconstruct a security object.</summary>
/// <param name="e">The <see cref="T:System.Security.SecurityElement" /> that contains the XML encoding to use to reconstruct the security object. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="e" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="e" /> is not a valid membership condition element. </exception>
// Token: 0x060033FA RID: 13306 RVA: 0x000B2CA4 File Offset: 0x000B0EA4
public void FromXml(SecurityElement e)
{
this.FromXml(e, null);
}
/// <summary>Uses the specified XML encoding to reconstruct a security object, using the specified policy level context.</summary>
/// <param name="e">The <see cref="T:System.Security.SecurityElement" /> that contains the XML encoding to use to reconstruct the security object. </param>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context for resolving <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="e" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="e" /> is not a valid membership condition element. </exception>
// Token: 0x060033FB RID: 13307 RVA: 0x000B2CB0 File Offset: 0x000B0EB0
public void FromXml(SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
}
/// <summary>Gets a hash code for the current membership condition.</summary>
/// <returns>0 (zero).</returns>
// Token: 0x060033FC RID: 13308 RVA: 0x000B2CCC File Offset: 0x000B0ECC
public override int GetHashCode()
{
return 0;
}
/// <summary>Returns a string representation of the membership condition.</summary>
/// <returns>A string representation of the membership condition.</returns>
// Token: 0x060033FD RID: 13309 RVA: 0x000B2CD0 File Offset: 0x000B0ED0
public override string ToString()
{
return "GAC";
}
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
/// <returns>A <see cref="T:System.Security.SecurityElement" /> that contains the XML encoding of the security object, including any state information.</returns>
// Token: 0x060033FE RID: 13310 RVA: 0x000B2CD8 File Offset: 0x000B0ED8
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// <summary>Creates an XML encoding of the security object and its current state, using the specified policy level context.</summary>
/// <returns>A <see cref="T:System.Security.SecurityElement" /> that contains the XML encoding of the security object, including any state information.</returns>
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context for resolving <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
// Token: 0x060033FF RID: 13311 RVA: 0x000B2CE4 File Offset: 0x000B0EE4
public SecurityElement ToXml(PolicyLevel level)
{
return MembershipConditionHelper.Element(typeof(GacMembershipCondition), this.version);
}
// Token: 0x04001550 RID: 5456
private readonly int version = 1;
}
}