5
// Jb Evain (jbevain@gmail.com)
7
// Copyright (c) 2008 - 2010 Jb Evain
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.
31
namespace Mono.Cecil {
33
public class ExportedType : IMetadataTokenProvider {
40
ExportedType declaring_type;
41
internal MetadataToken token;
43
public string Namespace {
44
get { return @namespace; }
45
set { @namespace = value; }
53
public TypeAttributes Attributes {
54
get { return (TypeAttributes) attributes; }
55
set { attributes = (uint) value; }
58
public IMetadataScope Scope {
60
if (declaring_type != null)
61
return declaring_type.Scope;
67
public ExportedType DeclaringType {
68
get { return declaring_type; }
69
set { declaring_type = value; }
72
public MetadataToken MetadataToken {
74
set { token = value; }
77
public int Identifier {
78
get { return identifier; }
79
set { identifier = value; }
82
#region TypeAttributes
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
149
public bool IsAbstract {
150
get { return attributes.GetAttributes ((uint) TypeAttributes.Abstract); }
151
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Abstract, value); }
154
public bool IsSealed {
155
get { return attributes.GetAttributes ((uint) TypeAttributes.Sealed); }
156
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Sealed, value); }
159
public bool IsSpecialName {
160
get { return attributes.GetAttributes ((uint) TypeAttributes.SpecialName); }
161
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.SpecialName, value); }
164
public bool IsImport {
165
get { return attributes.GetAttributes ((uint) TypeAttributes.Import); }
166
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Import, value); }
169
public bool IsSerializable {
170
get { return attributes.GetAttributes ((uint) TypeAttributes.Serializable); }
171
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Serializable, value); }
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); }
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); }
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); }
189
public bool IsBeforeFieldInit {
190
get { return attributes.GetAttributes ((uint) TypeAttributes.BeforeFieldInit); }
191
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.BeforeFieldInit, value); }
194
public bool IsRuntimeSpecialName {
195
get { return attributes.GetAttributes ((uint) TypeAttributes.RTSpecialName); }
196
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.RTSpecialName, value); }
199
public bool HasSecurity {
200
get { return attributes.GetAttributes ((uint) TypeAttributes.HasSecurity); }
201
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.HasSecurity, value); }
206
public bool IsForwarder {
207
get { return attributes.GetAttributes ((uint) TypeAttributes.Forwarder); }
208
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Forwarder, value); }
211
public string FullName {
213
if (declaring_type != null)
214
return declaring_type.FullName + "/" + name;
216
if (string.IsNullOrEmpty (@namespace))
219
return @namespace + "." + name;
223
public ExportedType (string @namespace, string name, IMetadataScope scope)
225
this.@namespace = @namespace;
230
public override string ToString ()