summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Security/Permissions/FileDialogPermission.cs
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2017-02-10 11:35:12 (GMT)
committerJiyoung Yun <jy910.yun@samsung.com>2017-02-10 11:35:12 (GMT)
commit4b11dc566a5bbfa1378d6266525c281b028abcc8 (patch)
treeb48831a898906734f8884d08b6e18f1144ee2b82 /src/mscorlib/src/System/Security/Permissions/FileDialogPermission.cs
parentdb20f3f1bb8595633a7e16c8900fd401a453a6b5 (diff)
downloadcoreclr-4b11dc566a5bbfa1378d6266525c281b028abcc8.zip
coreclr-4b11dc566a5bbfa1378d6266525c281b028abcc8.tar.gz
coreclr-4b11dc566a5bbfa1378d6266525c281b028abcc8.tar.bz2
Imported Upstream version 1.0.0.9910upstream/1.0.0.9910
Diffstat (limited to 'src/mscorlib/src/System/Security/Permissions/FileDialogPermission.cs')
-rw-r--r--src/mscorlib/src/System/Security/Permissions/FileDialogPermission.cs158
1 files changed, 0 insertions, 158 deletions
diff --git a/src/mscorlib/src/System/Security/Permissions/FileDialogPermission.cs b/src/mscorlib/src/System/Security/Permissions/FileDialogPermission.cs
deleted file mode 100644
index 98a7d54..0000000
--- a/src/mscorlib/src/System/Security/Permissions/FileDialogPermission.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Security.Permissions {
- using System;
- using System.Text;
- using System.Security;
- using System.Security.Util;
- using System.IO;
- using System.Runtime.Serialization;
- using System.Reflection;
- using System.Collections;
- using System.Globalization;
- using System.Diagnostics.Contracts;
-
-[Serializable]
-[Flags]
-[System.Runtime.InteropServices.ComVisible(true)]
- public enum FileDialogPermissionAccess {
- None = 0x00,
-
- Open = 0x01,
-
- Save = 0x02,
-
- OpenSave = Open | Save
-
- }
-
- [Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
- public sealed class FileDialogPermission : CodeAccessPermission, IUnrestrictedPermission, IBuiltInPermission {
- FileDialogPermissionAccess access;
-
- public FileDialogPermission(PermissionState state) {
- if (state == PermissionState.Unrestricted) {
- SetUnrestricted(true);
- }
- else if (state == PermissionState.None) {
- SetUnrestricted(false);
- Reset();
- }
- else {
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidPermissionState"));
- }
- }
-
- public FileDialogPermission(FileDialogPermissionAccess access) {
- VerifyAccess(access);
- this.access = access;
- }
-
- public FileDialogPermissionAccess Access {
- get {
- return access;
- }
-
- set {
- VerifyAccess(value);
- access = value;
- }
- }
-
- public override IPermission Copy() {
- return new FileDialogPermission(this.access);
- }
-
- /// <internalonly/>
- int IBuiltInPermission.GetTokenIndex() {
- return FileDialogPermission.GetTokenIndex();
- }
-
- internal static int GetTokenIndex() {
- return BuiltInPermissionIndex.FileDialogPermissionIndex;
- }
-
- public override IPermission Intersect(IPermission target) {
- if (target == null) {
- return null;
- }
- else if (!VerifyType(target)) {
- throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName));
- }
-
- FileDialogPermission operand = (FileDialogPermission)target;
-
- FileDialogPermissionAccess intersectAccess = access & operand.Access;
-
- if (intersectAccess == FileDialogPermissionAccess.None)
- return null;
- else
- return new FileDialogPermission(intersectAccess);
- }
-
- public override bool IsSubsetOf(IPermission target) {
- if (target == null) {
- // Only safe subset if this is empty
- return access == FileDialogPermissionAccess.None;
- }
-
- try {
- FileDialogPermission operand = (FileDialogPermission)target;
- if (operand.IsUnrestricted()) {
- return true;
- }
- else if (this.IsUnrestricted()) {
- return false;
- }
- else {
- int open = (int)(access & FileDialogPermissionAccess.Open);
- int save = (int)(access & FileDialogPermissionAccess.Save);
- int openTarget = (int)(operand.Access & FileDialogPermissionAccess.Open);
- int saveTarget = (int)(operand.Access & FileDialogPermissionAccess.Save);
-
- return open <= openTarget && save <= saveTarget;
- }
- }
- catch (InvalidCastException) {
- throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName));
- }
-
- }
-
- public bool IsUnrestricted() {
- return access == FileDialogPermissionAccess.OpenSave;
- }
-
- void Reset() {
- access = FileDialogPermissionAccess.None;
- }
-
- void SetUnrestricted( bool unrestricted ) {
- if (unrestricted) {
- access = FileDialogPermissionAccess.OpenSave;
- }
- }
-
- public override IPermission Union(IPermission target) {
- if (target == null) {
- return this.Copy();
- }
- else if (!VerifyType(target)) {
- throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName));
- }
-
- FileDialogPermission operand = (FileDialogPermission)target;
- return new FileDialogPermission(access | operand.Access);
- }
-
- static void VerifyAccess(FileDialogPermissionAccess access) {
- if ((access & ~FileDialogPermissionAccess.OpenSave) != 0 ) {
- throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)access));
- }
- Contract.EndContractBlock();
- }
- }
-}