scripts
This commit is contained in:
@@ -0,0 +1,267 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.Security.Permissions
|
||||
{
|
||||
/// <summary>Controls the permissions related to user interfaces and the clipboard. This class cannot be inherited.</summary>
|
||||
// Token: 0x02000571 RID: 1393
|
||||
[ComVisible(true)]
|
||||
[Serializable]
|
||||
public sealed class UIPermission : CodeAccessPermission, IBuiltInPermission, IUnrestrictedPermission
|
||||
{
|
||||
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.UIPermission" /> class with either fully restricted or unrestricted access, as specified.</summary>
|
||||
/// <param name="state">One of the <see cref="T:System.Security.Permissions.PermissionState" /> values. </param>
|
||||
/// <exception cref="T:System.ArgumentException">The <paramref name="state" /> parameter is not a valid <see cref="T:System.Security.Permissions.PermissionState" />. </exception>
|
||||
// Token: 0x060032F8 RID: 13048 RVA: 0x000AF840 File Offset: 0x000ADA40
|
||||
public UIPermission(PermissionState state)
|
||||
{
|
||||
if (CodeAccessPermission.CheckPermissionState(state, true) == PermissionState.Unrestricted)
|
||||
{
|
||||
this._clipboard = UIPermissionClipboard.AllClipboard;
|
||||
this._window = UIPermissionWindow.AllWindows;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.UIPermission" /> class with the permissions for the clipboard, and no access to windows.</summary>
|
||||
/// <param name="clipboardFlag">One of the <see cref="T:System.Security.Permissions.UIPermissionClipboard" /> values. </param>
|
||||
/// <exception cref="T:System.ArgumentException">The <paramref name="clipboardFlag" /> parameter is not a valid <see cref="T:System.Security.Permissions.UIPermissionClipboard" /> value. </exception>
|
||||
// Token: 0x060032F9 RID: 13049 RVA: 0x000AF864 File Offset: 0x000ADA64
|
||||
public UIPermission(UIPermissionClipboard clipboardFlag)
|
||||
{
|
||||
this.Clipboard = clipboardFlag;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.UIPermission" /> class with the permissions for windows, and no access to the clipboard.</summary>
|
||||
/// <param name="windowFlag">One of the <see cref="T:System.Security.Permissions.UIPermissionWindow" /> values. </param>
|
||||
/// <exception cref="T:System.ArgumentException">The <paramref name="windowFlag" /> parameter is not a valid <see cref="T:System.Security.Permissions.UIPermissionWindow" /> value. </exception>
|
||||
// Token: 0x060032FA RID: 13050 RVA: 0x000AF874 File Offset: 0x000ADA74
|
||||
public UIPermission(UIPermissionWindow windowFlag)
|
||||
{
|
||||
this.Window = windowFlag;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.UIPermission" /> class with the specified permissions for windows and the clipboard.</summary>
|
||||
/// <param name="windowFlag">One of the <see cref="T:System.Security.Permissions.UIPermissionWindow" /> values. </param>
|
||||
/// <param name="clipboardFlag">One of the <see cref="T:System.Security.Permissions.UIPermissionClipboard" /> values. </param>
|
||||
/// <exception cref="T:System.ArgumentException">The <paramref name="windowFlag" /> parameter is not a valid <see cref="T:System.Security.Permissions.UIPermissionWindow" /> value.-or- The <paramref name="clipboardFlag" /> parameter is not a valid <see cref="T:System.Security.Permissions.UIPermissionClipboard" /> value. </exception>
|
||||
// Token: 0x060032FB RID: 13051 RVA: 0x000AF884 File Offset: 0x000ADA84
|
||||
public UIPermission(UIPermissionWindow windowFlag, UIPermissionClipboard clipboardFlag)
|
||||
{
|
||||
this.Clipboard = clipboardFlag;
|
||||
this.Window = windowFlag;
|
||||
}
|
||||
|
||||
// Token: 0x060032FC RID: 13052 RVA: 0x000AF89C File Offset: 0x000ADA9C
|
||||
int IBuiltInPermission.GetTokenIndex()
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the clipboard access represented by the permission.</summary>
|
||||
/// <returns>One of the <see cref="T:System.Security.Permissions.UIPermissionClipboard" /> values.</returns>
|
||||
// Token: 0x17000A06 RID: 2566
|
||||
// (get) Token: 0x060032FD RID: 13053 RVA: 0x000AF8A0 File Offset: 0x000ADAA0
|
||||
// (set) Token: 0x060032FE RID: 13054 RVA: 0x000AF8A8 File Offset: 0x000ADAA8
|
||||
public UIPermissionClipboard Clipboard
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._clipboard;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(UIPermissionClipboard), value))
|
||||
{
|
||||
string text = string.Format(Locale.GetText("Invalid enum {0}"), value);
|
||||
throw new ArgumentException(text, "UIPermissionClipboard");
|
||||
}
|
||||
this._clipboard = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the window access represented by the permission.</summary>
|
||||
/// <returns>One of the <see cref="T:System.Security.Permissions.UIPermissionWindow" /> values.</returns>
|
||||
// Token: 0x17000A07 RID: 2567
|
||||
// (get) Token: 0x060032FF RID: 13055 RVA: 0x000AF8F8 File Offset: 0x000ADAF8
|
||||
// (set) Token: 0x06003300 RID: 13056 RVA: 0x000AF900 File Offset: 0x000ADB00
|
||||
public UIPermissionWindow Window
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._window;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(UIPermissionWindow), value))
|
||||
{
|
||||
string text = string.Format(Locale.GetText("Invalid enum {0}"), value);
|
||||
throw new ArgumentException(text, "UIPermissionWindow");
|
||||
}
|
||||
this._window = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates and returns an identical copy of the current permission.</summary>
|
||||
/// <returns>A copy of the current permission.</returns>
|
||||
// Token: 0x06003301 RID: 13057 RVA: 0x000AF950 File Offset: 0x000ADB50
|
||||
public override IPermission Copy()
|
||||
{
|
||||
return new UIPermission(this._window, this._clipboard);
|
||||
}
|
||||
|
||||
/// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary>
|
||||
/// <param name="esd">The XML encoding used to reconstruct the permission. </param>
|
||||
/// <exception cref="T:System.ArgumentNullException">The <paramref name="esd" /> parameter is null. </exception>
|
||||
/// <exception cref="T:System.ArgumentException">The <paramref name="esd" /> parameter is not a valid permission element.-or- The <paramref name="esd" /> parameter's version number is not valid. </exception>
|
||||
// Token: 0x06003302 RID: 13058 RVA: 0x000AF964 File Offset: 0x000ADB64
|
||||
public override void FromXml(SecurityElement esd)
|
||||
{
|
||||
CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
|
||||
if (CodeAccessPermission.IsUnrestricted(esd))
|
||||
{
|
||||
this._window = UIPermissionWindow.AllWindows;
|
||||
this._clipboard = UIPermissionClipboard.AllClipboard;
|
||||
}
|
||||
else
|
||||
{
|
||||
string text = esd.Attribute("Window");
|
||||
if (text == null)
|
||||
{
|
||||
this._window = UIPermissionWindow.NoWindows;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._window = (UIPermissionWindow)((int)Enum.Parse(typeof(UIPermissionWindow), text));
|
||||
}
|
||||
string text2 = esd.Attribute("Clipboard");
|
||||
if (text2 == null)
|
||||
{
|
||||
this._clipboard = UIPermissionClipboard.NoClipboard;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._clipboard = (UIPermissionClipboard)((int)Enum.Parse(typeof(UIPermissionClipboard), text2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates and returns a permission that is the intersection of the current permission and the specified permission.</summary>
|
||||
/// <returns>A new permission that represents the intersection of the current permission and the specified permission. This new permission is null if the intersection is empty.</returns>
|
||||
/// <param name="target">A permission to intersect with the current permission. It must be the same type as the current permission. </param>
|
||||
/// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is not null and is not of the same type as the current permission. </exception>
|
||||
// Token: 0x06003303 RID: 13059 RVA: 0x000AFA10 File Offset: 0x000ADC10
|
||||
public override IPermission Intersect(IPermission target)
|
||||
{
|
||||
UIPermission uipermission = this.Cast(target);
|
||||
if (uipermission == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
UIPermissionWindow uipermissionWindow = ((this._window >= uipermission._window) ? uipermission._window : this._window);
|
||||
UIPermissionClipboard uipermissionClipboard = ((this._clipboard >= uipermission._clipboard) ? uipermission._clipboard : this._clipboard);
|
||||
if (this.IsEmpty(uipermissionWindow, uipermissionClipboard))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new UIPermission(uipermissionWindow, uipermissionClipboard);
|
||||
}
|
||||
|
||||
/// <summary>Determines whether the current permission is a subset of the specified permission.</summary>
|
||||
/// <returns>true if the current permission is a subset of the specified permission; otherwise, false.</returns>
|
||||
/// <param name="target">A permission to test for the subset relationship. This permission must be the same type as the current permission. </param>
|
||||
/// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is not null and is not of the same type as the current permission. </exception>
|
||||
// Token: 0x06003304 RID: 13060 RVA: 0x000AFA8C File Offset: 0x000ADC8C
|
||||
public override bool IsSubsetOf(IPermission target)
|
||||
{
|
||||
UIPermission uipermission = this.Cast(target);
|
||||
if (uipermission == null)
|
||||
{
|
||||
return this.IsEmpty(this._window, this._clipboard);
|
||||
}
|
||||
return uipermission.IsUnrestricted() || (this._window <= uipermission._window && this._clipboard <= uipermission._clipboard);
|
||||
}
|
||||
|
||||
/// <summary>Returns a value indicating whether the current permission is unrestricted.</summary>
|
||||
/// <returns>true if the current permission is unrestricted; otherwise, false.</returns>
|
||||
// Token: 0x06003305 RID: 13061 RVA: 0x000AFAEC File Offset: 0x000ADCEC
|
||||
public bool IsUnrestricted()
|
||||
{
|
||||
return this._window == UIPermissionWindow.AllWindows && this._clipboard == UIPermissionClipboard.AllClipboard;
|
||||
}
|
||||
|
||||
/// <summary>Creates an XML encoding of the permission and its current state.</summary>
|
||||
/// <returns>An XML encoding of the permission, including any state information.</returns>
|
||||
// Token: 0x06003306 RID: 13062 RVA: 0x000AFB08 File Offset: 0x000ADD08
|
||||
public override SecurityElement ToXml()
|
||||
{
|
||||
SecurityElement securityElement = base.Element(1);
|
||||
if (this._window == UIPermissionWindow.AllWindows && this._clipboard == UIPermissionClipboard.AllClipboard)
|
||||
{
|
||||
securityElement.AddAttribute("Unrestricted", "true");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this._window != UIPermissionWindow.NoWindows)
|
||||
{
|
||||
securityElement.AddAttribute("Window", this._window.ToString());
|
||||
}
|
||||
if (this._clipboard != UIPermissionClipboard.NoClipboard)
|
||||
{
|
||||
securityElement.AddAttribute("Clipboard", this._clipboard.ToString());
|
||||
}
|
||||
}
|
||||
return securityElement;
|
||||
}
|
||||
|
||||
/// <summary>Creates a permission that is the union of the permission and the specified permission.</summary>
|
||||
/// <returns>A new permission that represents the union of the current permission and the specified permission.</returns>
|
||||
/// <param name="target">A permission to combine with the current permission. It must be the same type as the current permission. </param>
|
||||
/// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is not null and is not of the same type as the current permission. </exception>
|
||||
// Token: 0x06003307 RID: 13063 RVA: 0x000AFB98 File Offset: 0x000ADD98
|
||||
public override IPermission Union(IPermission target)
|
||||
{
|
||||
UIPermission uipermission = this.Cast(target);
|
||||
if (uipermission == null)
|
||||
{
|
||||
return this.Copy();
|
||||
}
|
||||
UIPermissionWindow uipermissionWindow = ((this._window <= uipermission._window) ? uipermission._window : this._window);
|
||||
UIPermissionClipboard uipermissionClipboard = ((this._clipboard <= uipermission._clipboard) ? uipermission._clipboard : this._clipboard);
|
||||
if (this.IsEmpty(uipermissionWindow, uipermissionClipboard))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new UIPermission(uipermissionWindow, uipermissionClipboard);
|
||||
}
|
||||
|
||||
// Token: 0x06003308 RID: 13064 RVA: 0x000AFC18 File Offset: 0x000ADE18
|
||||
private bool IsEmpty(UIPermissionWindow w, UIPermissionClipboard c)
|
||||
{
|
||||
return w == UIPermissionWindow.NoWindows && c == UIPermissionClipboard.NoClipboard;
|
||||
}
|
||||
|
||||
// Token: 0x06003309 RID: 13065 RVA: 0x000AFC28 File Offset: 0x000ADE28
|
||||
private UIPermission Cast(IPermission target)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
UIPermission uipermission = target as UIPermission;
|
||||
if (uipermission == null)
|
||||
{
|
||||
CodeAccessPermission.ThrowInvalidPermission(target, typeof(UIPermission));
|
||||
}
|
||||
return uipermission;
|
||||
}
|
||||
|
||||
// Token: 0x040014ED RID: 5357
|
||||
private const int version = 1;
|
||||
|
||||
// Token: 0x040014EE RID: 5358
|
||||
private UIPermissionWindow _window;
|
||||
|
||||
// Token: 0x040014EF RID: 5359
|
||||
private UIPermissionClipboard _clipboard;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user