Serialization bits for System.Collection.Hashtable, System.Reflection.AssemblyName...
[mono.git] / mcs / class / corlib / System.Security / CodeAccessPermission.cs
1 //
2 // System.Security.CodeAccessPermission.cs
3 //
4 // Author:
5 //   Miguel de Icaza (miguel@ximian.com)
6 //
7 // (C) Ximian, Inc. http://www.ximian.com
8 //
9
10 namespace System.Security {
11
12         public abstract class CodeAccessPermission : IPermission, ISecurityEncodable, IStackWalk
13         {
14                 ///<summary>Constructs a new instance of the System.Security.CodeAccessPermission class.</summary>
15                 protected CodeAccessPermission(){}
16
17                 ///<summary> Asserts that calling code can access the resource identified by the current instance through the code that      calls this method, even if callers have not been granted permission to      access the resource. </summary>
18                 ///<exception cref="System.Security.SecurityException">The calling code does not have System.Security.Permissions.SecurityPermissionFlag.Assertion. </exception>
19                 public void Assert()
20                 {
21                 }
22
23                 ///<summary> Returns a System.Security.CodeAccessPermission containing the same values as the current instance.</summary>
24                 ///<returns> A new System.Security.CodeAccessPermission instance that is value equal to the current instance.</returns>
25                 public abstract IPermission Copy();
26
27                 ///<summary>Forces a System.Security.SecurityException if all callers do not have the permission specified by the current instance.</summary>
28                 ///<exception cref="System.Security.SecurityException"> A caller does not have the permission specified by the current instance. A caller has called System.Security.CodeAccessPermission.Deny for the resource protected by the current instance. </exception>
29                 public void Demand()
30                 {
31                 }
32
33                 ///<summary> Denies access to the resources specified by the current instance through the code that calls this method.</summary>
34                 public void Deny(){}
35
36                 ///<summary> Reconstructs the state of a System.Security.CodeAccessPermission object using the specified XML encoding.</summary>
37                 ///<param name="elem">A System.Security.SecurityElement instance containing the XML encoding to use to reconstruct the state of a System.Security.CodeAccessPermission object.</param>
38                 ///<exception cref="System.ArgumentException">elem does not contain the XML encoding for a instance of the same type as the current instance.The version number of elem is not valid.</exception>
39                 public abstract void FromXml(SecurityElement elem);
40
41                 ///<summary> Returns a System.Security.CodeAccessPermission object that is the intersection of the current instance and the specified object.</summary>
42                 ///<param name="target">A System.Security.CodeAccessPermission instance to intersect with the current instance.</param>
43                 ///<returns> A new System.Security.CodeAccessPermission instance that represents the intersection of the current instance andtarget. If the intersection is empty or target is null, returns null. If the  current instance is unrestricted, returns a copy of target. Iftarget is unrestricted, returns a copy of the current instance.</returns>
44                 ///<exception cref="System.ArgumentException">target is not null and is not a System.Security.CodeAccessPermission object.</exception>
45                 public abstract IPermission Intersect(IPermission target);
46
47                 ///<summary>Determines whether the current instance is a subset of the specified      object.</summary>
48                 ///<param name="target">A System.Security.CodeAccessPermission instance that is to be tested for the subset relationship.</param>
49                 ///<returns>true if the current instance is a   subset of target; otherwise, false. If the current   instance is unrestricted, and target is not, returnsfalse. If target is unrestricted, returns true.</returns>
50                 ///<exception cref="System.ArgumentException">target is not null and is not of type System.Security.CodeAccessPermission.</exception>
51                 public abstract bool IsSubsetOf(IPermission target);
52
53                 ///<summary> Returns the XML representation of the state of the current instance.</summary>
54                 ///<returns> A System.String containing the XML  representation of the state of the current instance.</returns>
55                 public override string ToString()
56                 {
57                     return null;
58                 }
59
60                 ///<summary> Returns the XML encoding of the current instance.</summary>
61                 ///<returns>A System.Security.SecurityElement containing an XML encoding of the state of the current instance.</returns>
62                 public abstract SecurityElement ToXml();
63
64                 ///<summary> Returns a System.Security.CodeAccessPermission object that is the union of the current instance and the specified object.</summary>
65                 ///<param name="other">A System.Security.IPermission object of the same type as the current instance to be combined with the current instance.</param>
66                 ///<returns>If other is null, returns a copy of the current  instance using the System.Security.IPermission.Copy method.</returns>
67                 ///<exception cref="System.ArgumentException">other is not of type System.Security.CodeAccessPermission.</exception>
68                 ///<exception cref="System.NotSupportedException">other is not null.</exception>
69                 public virtual IPermission Union(IPermission other)
70                 {
71                     if (!(other is System.Security.CodeAccessPermission))
72                     {
73                         throw new System.ArgumentException(); // other is not of type System.Security.CodeAccessPermission.
74                     }
75                     if (null != other)
76                     {
77                         throw new System.NotSupportedException(); // other is not null.
78                     }
79                     return null;
80                 }
81
82                 public void PermitOnly(){}
83         }
84 }