~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/mono-addins/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExportedType.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// ExportedType.cs
 
3
//
 
4
// Author:
 
5
//   Jb Evain (jbevain@gmail.com)
 
6
//
 
7
// Copyright (c) 2008 - 2010 Jb Evain
 
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.
 
27
//
 
28
 
 
29
using System;
 
30
 
 
31
namespace Mono.Cecil {
 
32
 
 
33
        public class ExportedType : IMetadataTokenProvider {
 
34
 
 
35
                string @namespace;
 
36
                string name;
 
37
                uint attributes;
 
38
                IMetadataScope scope;
 
39
                int identifier;
 
40
                ExportedType declaring_type;
 
41
                internal MetadataToken token;
 
42
 
 
43
                public string Namespace {
 
44
                        get { return @namespace; }
 
45
                        set { @namespace = value; }
 
46
                }
 
47
 
 
48
                public string Name {
 
49
                        get { return name; }
 
50
                        set { name = value; }
 
51
                }
 
52
 
 
53
                public TypeAttributes Attributes {
 
54
                        get { return (TypeAttributes) attributes; }
 
55
                        set { attributes = (uint) value; }
 
56
                }
 
57
 
 
58
                public IMetadataScope Scope {
 
59
                        get {
 
60
                                if (declaring_type != null)
 
61
                                        return declaring_type.Scope;
 
62
 
 
63
                                return scope;
 
64
                        }
 
65
                }
 
66
 
 
67
                public ExportedType DeclaringType {
 
68
                        get { return declaring_type; }
 
69
                        set { declaring_type = value; }
 
70
                }
 
71
 
 
72
                public MetadataToken MetadataToken {
 
73
                        get { return token; }
 
74
                        set { token = value; }
 
75
                }
 
76
 
 
77
                public int Identifier {
 
78
                        get { return identifier; }
 
79
                        set { identifier = value; }
 
80
                }
 
81
 
 
82
                #region TypeAttributes
 
83
 
 
84
                public bool IsNotPublic {
 
85
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic); }
 
86
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic, value); }
 
87
                }
 
88
 
 
89
                public bool IsPublic {
 
90
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public); }
 
91
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public, value); }
 
92
                }
 
93
 
 
94
                public bool IsNestedPublic {
 
95
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic); }
 
96
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic, value); }
 
97
                }
 
98
 
 
99
                public bool IsNestedPrivate {
 
100
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate); }
 
101
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate, value); }
 
102
                }
 
103
 
 
104
                public bool IsNestedFamily {
 
105
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily); }
 
106
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily, value); }
 
107
                }
 
108
 
 
109
                public bool IsNestedAssembly {
 
110
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly); }
 
111
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly, value); }
 
112
                }
 
113
 
 
114
                public bool IsNestedFamilyAndAssembly {
 
115
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem); }
 
116
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem, value); }
 
117
                }
 
118
 
 
119
                public bool IsNestedFamilyOrAssembly {
 
120
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem); }
 
121
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem, value); }
 
122
                }
 
123
 
 
124
                public bool IsAutoLayout {
 
125
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout); }
 
126
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout, value); }
 
127
                }
 
128
 
 
129
                public bool IsSequentialLayout {
 
130
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout); }
 
131
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout, value); }
 
132
                }
 
133
 
 
134
                public bool IsExplicitLayout {
 
135
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout); }
 
136
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout, value); }
 
137
                }
 
138
 
 
139
                public bool IsClass {
 
140
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class); }
 
141
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class, value); }
 
142
                }
 
143
 
 
144
                public bool IsInterface {
 
145
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface); }
 
146
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface, value); }
 
147
                }
 
148
 
 
149
                public bool IsAbstract {
 
150
                        get { return attributes.GetAttributes ((uint) TypeAttributes.Abstract); }
 
151
                        set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Abstract, value); }
 
152
                }
 
153
 
 
154
                public bool IsSealed {
 
155
                        get { return attributes.GetAttributes ((uint) TypeAttributes.Sealed); }
 
156
                        set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Sealed, value); }
 
157
                }
 
158
 
 
159
                public bool IsSpecialName {
 
160
                        get { return attributes.GetAttributes ((uint) TypeAttributes.SpecialName); }
 
161
                        set { attributes = attributes.SetAttributes ((uint) TypeAttributes.SpecialName, value); }
 
162
                }
 
163
 
 
164
                public bool IsImport {
 
165
                        get { return attributes.GetAttributes ((uint) TypeAttributes.Import); }
 
166
                        set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Import, value); }
 
167
                }
 
168
 
 
169
                public bool IsSerializable {
 
170
                        get { return attributes.GetAttributes ((uint) TypeAttributes.Serializable); }
 
171
                        set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Serializable, value); }
 
172
                }
 
173
 
 
174
                public bool IsAnsiClass {
 
175
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass); }
 
176
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass, value); }
 
177
                }
 
178
 
 
179
                public bool IsUnicodeClass {
 
180
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass); }
 
181
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass, value); }
 
182
                }
 
183
 
 
184
                public bool IsAutoClass {
 
185
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass); }
 
186
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass, value); }
 
187
                }
 
188
 
 
189
                public bool IsBeforeFieldInit {
 
190
                        get { return attributes.GetAttributes ((uint) TypeAttributes.BeforeFieldInit); }
 
191
                        set { attributes = attributes.SetAttributes ((uint) TypeAttributes.BeforeFieldInit, value); }
 
192
                }
 
193
 
 
194
                public bool IsRuntimeSpecialName {
 
195
                        get { return attributes.GetAttributes ((uint) TypeAttributes.RTSpecialName); }
 
196
                        set { attributes = attributes.SetAttributes ((uint) TypeAttributes.RTSpecialName, value); }
 
197
                }
 
198
 
 
199
                public bool HasSecurity {
 
200
                        get { return attributes.GetAttributes ((uint) TypeAttributes.HasSecurity); }
 
201
                        set { attributes = attributes.SetAttributes ((uint) TypeAttributes.HasSecurity, value); }
 
202
                }
 
203
 
 
204
                #endregion
 
205
 
 
206
                public bool IsForwarder {
 
207
                        get { return attributes.GetAttributes ((uint) TypeAttributes.Forwarder); }
 
208
                        set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Forwarder, value); }
 
209
                }
 
210
 
 
211
                public string FullName {
 
212
                        get {
 
213
                                if (declaring_type != null)
 
214
                                        return declaring_type.FullName + "/" + name;
 
215
 
 
216
                                if (string.IsNullOrEmpty (@namespace))
 
217
                                        return name;
 
218
 
 
219
                                return @namespace + "." + name;
 
220
                        }
 
221
                }
 
222
 
 
223
                public ExportedType (string @namespace, string name, IMetadataScope scope)
 
224
                {
 
225
                        this.@namespace = @namespace;
 
226
                        this.name = name;
 
227
                        this.scope = scope;
 
228
                }
 
229
 
 
230
                public override string ToString ()
 
231
                {
 
232
                        return FullName;
 
233
                }
 
234
        }
 
235
}