using System; using System.Runtime.InteropServices; namespace System.Security.Permissions { /// Controls the ability to access files or folders through a File dialog box. This class cannot be inherited. // Token: 0x02000541 RID: 1345 [ComVisible(true)] [Serializable] public sealed class FileDialogPermission : CodeAccessPermission, IBuiltInPermission, IUnrestrictedPermission { /// Initializes a new instance of the class with either restricted or unrestricted permission, as specified. /// One of the values (Unrestricted or None). /// The parameter is not a valid value of . // Token: 0x06003131 RID: 12593 RVA: 0x000A9544 File Offset: 0x000A7744 public FileDialogPermission(PermissionState state) { if (CodeAccessPermission.CheckPermissionState(state, true) == PermissionState.Unrestricted) { this._access = FileDialogPermissionAccess.OpenSave; } else { this._access = FileDialogPermissionAccess.None; } } /// Initializes a new instance of the class with the specified access. /// A bitwise combination of the values. /// The parameter is not a valid combination of the values. // Token: 0x06003132 RID: 12594 RVA: 0x000A9578 File Offset: 0x000A7778 public FileDialogPermission(FileDialogPermissionAccess access) { this.Access = access; } // Token: 0x06003133 RID: 12595 RVA: 0x000A9588 File Offset: 0x000A7788 int IBuiltInPermission.GetTokenIndex() { return 1; } /// Gets or sets the permitted access to files. /// The permitted access to files. /// An attempt is made to set the parameter to a value that is not a valid combination of the values. // Token: 0x170009A0 RID: 2464 // (get) Token: 0x06003134 RID: 12596 RVA: 0x000A958C File Offset: 0x000A778C // (set) Token: 0x06003135 RID: 12597 RVA: 0x000A9594 File Offset: 0x000A7794 public FileDialogPermissionAccess Access { get { return this._access; } set { if (!Enum.IsDefined(typeof(FileDialogPermissionAccess), value)) { string text = string.Format(Locale.GetText("Invalid enum {0}"), value); throw new ArgumentException(text, "FileDialogPermissionAccess"); } this._access = value; } } /// Creates and returns an identical copy of the current permission. /// A copy of the current permission. // Token: 0x06003136 RID: 12598 RVA: 0x000A95E4 File Offset: 0x000A77E4 public override IPermission Copy() { return new FileDialogPermission(this._access); } /// 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 version number of the parameter is not supported. // Token: 0x06003137 RID: 12599 RVA: 0x000A95F4 File Offset: 0x000A77F4 public override void FromXml(SecurityElement esd) { CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1); if (CodeAccessPermission.IsUnrestricted(esd)) { this._access = FileDialogPermissionAccess.OpenSave; } else { string text = esd.Attribute("Access"); if (text == null) { this._access = FileDialogPermissionAccess.None; } else { this._access = (FileDialogPermissionAccess)((int)Enum.Parse(typeof(FileDialogPermissionAccess), text)); } } } /// 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: 0x06003138 RID: 12600 RVA: 0x000A9660 File Offset: 0x000A7860 public override IPermission Intersect(IPermission target) { FileDialogPermission fileDialogPermission = this.Cast(target); if (fileDialogPermission == null) { return null; } FileDialogPermissionAccess fileDialogPermissionAccess = this._access & fileDialogPermission._access; return (fileDialogPermissionAccess != FileDialogPermissionAccess.None) ? new FileDialogPermission(fileDialogPermissionAccess) : null; } /// 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 that is to be tested 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: 0x06003139 RID: 12601 RVA: 0x000A96A0 File Offset: 0x000A78A0 public override bool IsSubsetOf(IPermission target) { FileDialogPermission fileDialogPermission = this.Cast(target); return fileDialogPermission != null && (this._access & fileDialogPermission._access) == this._access; } /// Returns a value indicating whether the current permission is unrestricted. /// true if the current permission is unrestricted; otherwise, false. // Token: 0x0600313A RID: 12602 RVA: 0x000A96D4 File Offset: 0x000A78D4 public bool IsUnrestricted() { return this._access == FileDialogPermissionAccess.OpenSave; } /// Creates an XML encoding of the permission and its current state. /// An XML encoding of the permission, including state information. // Token: 0x0600313B RID: 12603 RVA: 0x000A96E0 File Offset: 0x000A78E0 public override SecurityElement ToXml() { SecurityElement securityElement = base.Element(1); switch (this._access) { case FileDialogPermissionAccess.Open: securityElement.AddAttribute("Access", "Open"); break; case FileDialogPermissionAccess.Save: securityElement.AddAttribute("Access", "Save"); break; case FileDialogPermissionAccess.OpenSave: securityElement.AddAttribute("Unrestricted", "true"); break; } return securityElement; } /// Creates a permission that is the union of the current 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 of the same type as the current permission. /// The parameter is not null and is not of the same type as the current permission. // Token: 0x0600313C RID: 12604 RVA: 0x000A9758 File Offset: 0x000A7958 public override IPermission Union(IPermission target) { FileDialogPermission fileDialogPermission = this.Cast(target); if (fileDialogPermission == null) { return this.Copy(); } if (this.IsUnrestricted() || fileDialogPermission.IsUnrestricted()) { return new FileDialogPermission(PermissionState.Unrestricted); } return new FileDialogPermission(this._access | fileDialogPermission._access); } // Token: 0x0600313D RID: 12605 RVA: 0x000A97AC File Offset: 0x000A79AC private FileDialogPermission Cast(IPermission target) { if (target == null) { return null; } FileDialogPermission fileDialogPermission = target as FileDialogPermission; if (fileDialogPermission == null) { CodeAccessPermission.ThrowInvalidPermission(target, typeof(FileDialogPermission)); } return fileDialogPermission; } // Token: 0x04001417 RID: 5143 private const int version = 1; // Token: 0x04001418 RID: 5144 private FileDialogPermissionAccess _access; } }