(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / corlib / System.Security.Permissions / HostProtectionAttribute.cs
blob1bee5588a60f56a2fb2bec162dd1ec21167c309c
1 //
2 // System.Security.Permissions.HostProtectionAttribute class
3 //
4 // Author:
5 // Sebastien Pouliot <sebastien@ximian.com>
6 //
7 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #if NET_2_0
31 namespace System.Security.Permissions {
33 [AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct |
34 AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Delegate,
35 AllowMultiple = true, Inherited = false)]
36 [Serializable]
37 public sealed class HostProtectionAttribute : CodeAccessSecurityAttribute {
39 private HostProtectionResource _resources;
41 public HostProtectionAttribute ()
42 : base (SecurityAction.LinkDemand)
46 public HostProtectionAttribute (SecurityAction action)
47 : base (action)
49 if (action != SecurityAction.LinkDemand) {
50 string msg = String.Format (Locale.GetText ("Only {0} is accepted."), SecurityAction.LinkDemand);
51 throw new ArgumentException (msg, "action");
56 public bool ExternalProcessMgmt {
57 get { return ((_resources & HostProtectionResource.ExternalProcessMgmt) != 0); }
58 set {
59 if (value) {
60 _resources |= HostProtectionResource.ExternalProcessMgmt;
62 else {
63 _resources &= HostProtectionResource.ExternalProcessMgmt;
68 public bool ExternalThreading {
69 get { return ((_resources & HostProtectionResource.ExternalThreading) != 0); }
70 set {
71 if (value) {
72 _resources |= HostProtectionResource.ExternalThreading;
74 else {
75 _resources &= HostProtectionResource.ExternalThreading;
80 public bool MayLeakOnAbort {
81 get { return ((_resources & HostProtectionResource.MayLeakOnAbort) != 0); }
82 set {
83 if (value) {
84 _resources |= HostProtectionResource.MayLeakOnAbort;
86 else {
87 _resources &= HostProtectionResource.MayLeakOnAbort;
92 public bool SecurityInfrastructure {
93 get { return ((_resources & HostProtectionResource.SecurityInfrastructure) != 0); }
94 set {
95 if (value) {
96 _resources |= HostProtectionResource.SecurityInfrastructure;
98 else {
99 _resources &= HostProtectionResource.SecurityInfrastructure;
104 public bool SelfAffectingProcessMgmt {
105 get { return ((_resources & HostProtectionResource.SelfAffectingProcessMgmt) != 0); }
106 set {
107 if (value) {
108 _resources |= HostProtectionResource.SelfAffectingProcessMgmt;
110 else {
111 _resources &= HostProtectionResource.SelfAffectingProcessMgmt;
116 public bool SelfAffectingThreading {
117 get { return ((_resources & HostProtectionResource.SelfAffectingThreading) != 0); }
118 set {
119 if (value) {
120 _resources |= HostProtectionResource.SelfAffectingThreading;
122 else {
123 _resources &= HostProtectionResource.SelfAffectingThreading;
128 public bool SharedState {
129 get { return ((_resources & HostProtectionResource.SharedState) != 0); }
130 set {
131 if (value) {
132 _resources |= HostProtectionResource.SharedState;
134 else {
135 _resources &= HostProtectionResource.SharedState;
140 public bool Synchronization {
141 get { return ((_resources & HostProtectionResource.Synchronization) != 0); }
142 set {
143 if (value) {
144 _resources |= HostProtectionResource.Synchronization;
146 else {
147 _resources &= HostProtectionResource.Synchronization;
152 public bool UI {
153 get { return ((_resources & HostProtectionResource.UI) != 0); }
154 set {
155 if (value) {
156 _resources |= HostProtectionResource.UI;
158 else {
159 _resources &= HostProtectionResource.UI;
164 public HostProtectionResource Resources {
165 get { return _resources; }
166 set { _resources = value; }
170 public override IPermission CreatePermission ()
172 // looks like permission is internal
173 return new HostProtectionPermission (_resources);
178 #endif