2 // SecurityDeclaration.cs
5 // Jb Evain (jbevain@gmail.com)
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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 namespace Mono.Cecil {
32 using System.Collections;
33 using System.Security;
35 public sealed class SecurityDeclaration : IRequireResolving, IAnnotationProvider, IReflectionVisitable {
37 SecurityAction m_action;
38 SecurityDeclarationReader m_reader;
39 IDictionary m_annotations;
41 #if !CF_1_0 && !CF_2_0
42 PermissionSet m_permSet;
48 public SecurityAction Action {
49 get { return m_action; }
50 set { m_action = value; }
53 #if !CF_1_0 && !CF_2_0
54 public PermissionSet PermissionSet {
55 get { return m_permSet; }
56 set { m_permSet = value; }
60 public bool Resolved {
61 get { return m_resolved; }
62 set { m_resolved = value; }
66 get { return m_blob; }
67 set { m_blob = value; }
70 IDictionary IAnnotationProvider.Annotations {
72 if (m_annotations == null)
73 m_annotations = new Hashtable ();
78 public SecurityDeclaration (SecurityAction action)
83 internal SecurityDeclaration (SecurityAction action, SecurityDeclarationReader reader)
89 public SecurityDeclaration Clone ()
94 internal static SecurityDeclaration Clone (SecurityDeclaration sec)
96 SecurityDeclaration sd = new SecurityDeclaration (sec.Action);
103 #if !CF_1_0 && !CF_2_0
104 sd.PermissionSet = sec.PermissionSet.Copy ();
109 public bool Resolve ()
114 if (m_reader == null)
117 SecurityDeclaration clone = m_reader.FromByteArray (m_action, m_blob, true);
121 m_action = clone.Action;
122 #if !CF_1_0 && !CF_2_0
123 m_permSet = clone.PermissionSet.Copy ();
130 public void Accept (IReflectionVisitor visitor)
132 visitor.VisitSecurityDeclaration (this);