using System; using System.Runtime.InteropServices; namespace System.Security.Permissions { /// Controls the permissions related to user interfaces and the clipboard. This class cannot be inherited. // Token: 0x02000571 RID: 1393 [ComVisible(true)] [Serializable] public sealed class UIPermission : CodeAccessPermission, IBuiltInPermission, IUnrestrictedPermission { /// Initializes a new instance of the class with either fully restricted or unrestricted access, as specified. /// One of the values. /// The parameter is not a valid . // 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; } } /// Initializes a new instance of the class with the permissions for the clipboard, and no access to windows. /// One of the values. /// The parameter is not a valid value. // Token: 0x060032F9 RID: 13049 RVA: 0x000AF864 File Offset: 0x000ADA64 public UIPermission(UIPermissionClipboard clipboardFlag) { this.Clipboard = clipboardFlag; } /// Initializes a new instance of the class with the permissions for windows, and no access to the clipboard. /// One of the values. /// The parameter is not a valid value. // Token: 0x060032FA RID: 13050 RVA: 0x000AF874 File Offset: 0x000ADA74 public UIPermission(UIPermissionWindow windowFlag) { this.Window = windowFlag; } /// Initializes a new instance of the class with the specified permissions for windows and the clipboard. /// One of the values. /// One of the values. /// The parameter is not a valid value.-or- The parameter is not a valid value. // 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; } /// Gets or sets the clipboard access represented by the permission. /// One of the values. // 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; } } /// Gets or sets the window access represented by the permission. /// One of the values. // 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; } } /// Creates and returns an identical copy of the current permission. /// A copy of the current permission. // Token: 0x06003301 RID: 13057 RVA: 0x000AF950 File Offset: 0x000ADB50 public override IPermission Copy() { return new UIPermission(this._window, this._clipboard); } /// Reconstructs a permission with a specified state from an XML encoding. /// The XML encoding used to reconstruct the permission. /// The parameter is null. /// The parameter is not a valid permission element.-or- The parameter's version number is not valid. // 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)); } } } /// Creates and returns a permission that is the intersection of the current permission and the specified permission. /// 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. /// A permission to intersect with the current permission. It must be the same type as the current permission. /// The parameter is not null and is not of the same type as the current permission. // 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); } /// Determines whether the current permission is a subset of the specified permission. /// true if the current permission is a subset of the specified permission; otherwise, false. /// A permission to test for the subset relationship. This permission must be the same type as the current permission. /// The parameter is not null and is not of the same type as the current permission. // 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); } /// Returns a value indicating whether the current permission is unrestricted. /// true if the current permission is unrestricted; otherwise, false. // Token: 0x06003305 RID: 13061 RVA: 0x000AFAEC File Offset: 0x000ADCEC public bool IsUnrestricted() { return this._window == UIPermissionWindow.AllWindows && this._clipboard == UIPermissionClipboard.AllClipboard; } /// Creates an XML encoding of the permission and its current state. /// An XML encoding of the permission, including any state information. // 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; } /// Creates a permission that is the union of the permission and the specified permission. /// A new permission that represents the union of the current permission and the specified permission. /// A permission to combine with the current permission. It must be the same type as the current permission. /// The parameter is not null and is not of the same type as the current permission. // 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; } }