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

154 lines
5.4 KiB
C#

using System;
using System.Runtime.InteropServices;
namespace System.Security.Policy
{
/// <summary>Defines evidence that represents permission requests. This class cannot be inherited.</summary>
// Token: 0x02000597 RID: 1431
[ComVisible(true)]
[Serializable]
public sealed class PermissionRequestEvidence : IBuiltInEvidence
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.PermissionRequestEvidence" /> class with the permission request of a code assembly.</summary>
/// <param name="request">The minimum permissions the code requires to run. </param>
/// <param name="optional">The permissions the code can use if they are granted, but that are not required. </param>
/// <param name="denied">The permissions the code explicitly asks not to be granted. </param>
// Token: 0x06003442 RID: 13378 RVA: 0x000B3AF0 File Offset: 0x000B1CF0
public PermissionRequestEvidence(PermissionSet request, PermissionSet optional, PermissionSet denied)
{
if (request != null)
{
this.requested = new PermissionSet(request);
}
if (optional != null)
{
this.optional = new PermissionSet(optional);
}
if (denied != null)
{
this.denied = new PermissionSet(denied);
}
}
// Token: 0x06003443 RID: 13379 RVA: 0x000B3B3C File Offset: 0x000B1D3C
int IBuiltInEvidence.GetRequiredSize(bool verbose)
{
int num = ((!verbose) ? 1 : 3);
if (this.requested != null)
{
int num2 = this.requested.ToXml().ToString().Length + ((!verbose) ? 0 : 5);
num += num2;
}
if (this.optional != null)
{
int num3 = this.optional.ToXml().ToString().Length + ((!verbose) ? 0 : 5);
num += num3;
}
if (this.denied != null)
{
int num4 = this.denied.ToXml().ToString().Length + ((!verbose) ? 0 : 5);
num += num4;
}
return num;
}
// Token: 0x06003444 RID: 13380 RVA: 0x000B3BF4 File Offset: 0x000B1DF4
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
{
return 0;
}
// Token: 0x06003445 RID: 13381 RVA: 0x000B3BF8 File Offset: 0x000B1DF8
[MonoTODO("IBuiltInEvidence")]
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
{
return 0;
}
/// <summary>Gets the permissions the code explicitly asks not to be granted.</summary>
/// <returns>The permissions the code explicitly asks not to be granted.</returns>
// Token: 0x17000A45 RID: 2629
// (get) Token: 0x06003446 RID: 13382 RVA: 0x000B3BFC File Offset: 0x000B1DFC
public PermissionSet DeniedPermissions
{
get
{
return this.denied;
}
}
/// <summary>Gets the permissions the code can use if they are granted, but are not required.</summary>
/// <returns>The permissions the code can use if they are granted, but are not required.</returns>
// Token: 0x17000A46 RID: 2630
// (get) Token: 0x06003447 RID: 13383 RVA: 0x000B3C04 File Offset: 0x000B1E04
public PermissionSet OptionalPermissions
{
get
{
return this.optional;
}
}
/// <summary>Gets the minimum permissions the code requires to run.</summary>
/// <returns>The minimum permissions the code requires to run.</returns>
// Token: 0x17000A47 RID: 2631
// (get) Token: 0x06003448 RID: 13384 RVA: 0x000B3C0C File Offset: 0x000B1E0C
public PermissionSet RequestedPermissions
{
get
{
return this.requested;
}
}
/// <summary>Creates an equivalent copy of the current <see cref="T:System.Security.Policy.PermissionRequestEvidence" />.</summary>
/// <returns>An equivalent copy of the current <see cref="T:System.Security.Policy.PermissionRequestEvidence" />.</returns>
// Token: 0x06003449 RID: 13385 RVA: 0x000B3C14 File Offset: 0x000B1E14
public PermissionRequestEvidence Copy()
{
return new PermissionRequestEvidence(this.requested, this.optional, this.denied);
}
/// <summary>Gets a string representation of the state of the <see cref="T:System.Security.Policy.PermissionRequestEvidence" />.</summary>
/// <returns>A representation of the state of the <see cref="T:System.Security.Policy.PermissionRequestEvidence" />.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600344A RID: 13386 RVA: 0x000B3C30 File Offset: 0x000B1E30
public override string ToString()
{
SecurityElement securityElement = new SecurityElement("System.Security.Policy.PermissionRequestEvidence");
securityElement.AddAttribute("version", "1");
if (this.requested != null)
{
SecurityElement securityElement2 = new SecurityElement("Request");
securityElement2.AddChild(this.requested.ToXml());
securityElement.AddChild(securityElement2);
}
if (this.optional != null)
{
SecurityElement securityElement3 = new SecurityElement("Optional");
securityElement3.AddChild(this.optional.ToXml());
securityElement.AddChild(securityElement3);
}
if (this.denied != null)
{
SecurityElement securityElement4 = new SecurityElement("Denied");
securityElement4.AddChild(this.denied.ToXml());
securityElement.AddChild(securityElement4);
}
return securityElement.ToString();
}
// Token: 0x0400155E RID: 5470
private PermissionSet requested;
// Token: 0x0400155F RID: 5471
private PermissionSet optional;
// Token: 0x04001560 RID: 5472
private PermissionSet denied;
}
}