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

« back to all changes in this revision

Viewing changes to external/mono-addins/Mono.Addins/Mono.Addins.Database/IAssemblyReflector.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
// IAssemblyReflector.cs
 
2
//
 
3
// Author:
 
4
//   Lluis Sanchez Gual <lluis@novell.com>
 
5
//
 
6
// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
 
7
//
 
8
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
9
// of this software and associated documentation files (the "Software"), to deal
 
10
// in the Software without restriction, including without limitation the rights
 
11
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
12
// copies of the Software, and to permit persons to whom the Software is
 
13
// furnished to do so, subject to the following conditions:
 
14
//
 
15
// The above copyright notice and this permission notice shall be included in
 
16
// all copies or substantial portions of the Software.
 
17
//
 
18
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
19
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
20
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
21
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
22
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
23
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
24
// THE SOFTWARE.
 
25
//
 
26
//
 
27
 
 
28
using System;
 
29
using System.Collections;
 
30
using System.Collections.Generic;
 
31
using System.IO;
 
32
 
 
33
namespace Mono.Addins.Database
 
34
{
 
35
        /// <summary>
 
36
        /// An assembly reflector
 
37
        /// </summary>
 
38
        /// <remarks>
 
39
        /// This interface can be implemented to provide a custom method for getting information about assemblies.
 
40
        /// </remarks>
 
41
        public interface IAssemblyReflector
 
42
        {
 
43
                /// <summary>
 
44
                /// Called to initialize the assembly reflector
 
45
                /// </summary>
 
46
                /// <param name='locator'>
 
47
                /// IAssemblyLocator instance which can be used to locate referenced assemblies.
 
48
                /// </param>
 
49
                void Initialize (IAssemblyLocator locator);
 
50
                
 
51
                /// <summary>
 
52
                /// Gets a list of custom attributes
 
53
                /// </summary>
 
54
                /// <returns>
 
55
                /// The custom attributes.
 
56
                /// </returns>
 
57
                /// <param name='obj'>
 
58
                /// An assembly, class or class member
 
59
                /// </param>
 
60
                /// <param name='type'>
 
61
                /// Type of the attribute to be returned. It will always be one of the attribute types
 
62
                /// defined in Mono.Addins.
 
63
                /// </param>
 
64
                /// <param name='inherit'>
 
65
                /// 'true' if inherited attributes must be returned
 
66
                /// </param>
 
67
                object[] GetCustomAttributes (object obj, Type type, bool inherit);
 
68
                
 
69
                /// <summary>
 
70
                /// Gets a list of custom attributes
 
71
                /// </summary>
 
72
                /// <returns>
 
73
                /// The attributes.
 
74
                /// </returns>
 
75
                /// <param name='obj'>
 
76
                /// An assembly, class or class member
 
77
                /// </param>
 
78
                /// <param name='type'>
 
79
                /// Base type of the attribute to be returned
 
80
                /// </param>
 
81
                /// <param name='inherit'>
 
82
                /// 'true' if inherited attributes must be returned
 
83
                /// </param>
 
84
                List<CustomAttribute> GetRawCustomAttributes (object obj, Type type, bool inherit);
 
85
                
 
86
                /// <summary>
 
87
                /// Loads an assembly.
 
88
                /// </summary>
 
89
                /// <returns>
 
90
                /// The loaded assembly
 
91
                /// </returns>
 
92
                /// <param name='file'>
 
93
                /// Path of the assembly.
 
94
                /// </param>
 
95
                object LoadAssembly (string file);
 
96
                
 
97
                /// <summary>
 
98
                /// Loads the assembly specified in an assembly reference
 
99
                /// </summary>
 
100
                /// <returns>
 
101
                /// The assembly
 
102
                /// </returns>
 
103
                /// <param name='asmReference'>
 
104
                /// An assembly reference
 
105
                /// </param>
 
106
                object LoadAssemblyFromReference (object asmReference);
 
107
                
 
108
                /// <summary>
 
109
                /// Gets the names of all resources embedded in an assembly
 
110
                /// </summary>
 
111
                /// <returns>
 
112
                /// The names of the resources
 
113
                /// </returns>
 
114
                /// <param name='asm'>
 
115
                /// An assembly
 
116
                /// </param>
 
117
                string[] GetResourceNames (object asm);
 
118
                
 
119
                /// <summary>
 
120
                /// Gets the data stream of a resource
 
121
                /// </summary>
 
122
                /// <returns>
 
123
                /// The stream.
 
124
                /// </returns>
 
125
                /// <param name='asm'>
 
126
                /// An assembly
 
127
                /// </param>
 
128
                /// <param name='resourceName'>
 
129
                /// The name of a resource
 
130
                /// </param>
 
131
                Stream GetResourceStream (object asm, string resourceName);
 
132
                
 
133
                /// <summary>
 
134
                /// Gets all types defined in an assembly
 
135
                /// </summary>
 
136
                /// <returns>
 
137
                /// The types
 
138
                /// </returns>
 
139
                /// <param name='asm'>
 
140
                /// An assembly
 
141
                /// </param>
 
142
                IEnumerable GetAssemblyTypes (object asm);
 
143
                
 
144
                /// <summary>
 
145
                /// Gets all assembly references of an assembly
 
146
                /// </summary>
 
147
                /// <returns>
 
148
                /// A list of assembly references
 
149
                /// </returns>
 
150
                /// <param name='asm'>
 
151
                /// An assembly
 
152
                /// </param>
 
153
                IEnumerable GetAssemblyReferences (object asm);
 
154
                
 
155
                /// <summary>
 
156
                /// Looks for a type in an assembly
 
157
                /// </summary>
 
158
                /// <returns>
 
159
                /// The type.
 
160
                /// </returns>
 
161
                /// <param name='asm'>
 
162
                /// An assembly
 
163
                /// </param>
 
164
                /// <param name='typeName'>
 
165
                /// Name of the type
 
166
                /// </param>
 
167
                object GetType (object asm, string typeName);
 
168
                
 
169
                
 
170
                /// <summary>
 
171
                /// Gets a custom attribute
 
172
                /// </summary>
 
173
                /// <returns>
 
174
                /// The custom attribute.
 
175
                /// </returns>
 
176
                /// <param name='obj'>
 
177
                /// An assembly, class or class member
 
178
                /// </param>
 
179
                /// <param name='type'>
 
180
                /// Base type of the attribute to be returned. It will always be one of the attribute types
 
181
                /// defined in Mono.Addins.
 
182
                /// </param>
 
183
                /// <param name='inherit'>
 
184
                /// 'true' if inherited attributes must be returned
 
185
                /// </param>
 
186
                object GetCustomAttribute (object obj, Type type, bool inherit);
 
187
                
 
188
                /// <summary>
 
189
                /// Gets the name of a type (not including namespace)
 
190
                /// </summary>
 
191
                /// <returns>
 
192
                /// The type name.
 
193
                /// </returns>
 
194
                /// <param name='type'>
 
195
                /// A type
 
196
                /// </param>
 
197
                string GetTypeName (object type);
 
198
                
 
199
                /// <summary>
 
200
                /// Gets the full name of a type (including namespace)
 
201
                /// </summary>
 
202
                /// <returns>
 
203
                /// The full name of the type
 
204
                /// </returns>
 
205
                /// <param name='type'>
 
206
                /// A type
 
207
                /// </param>
 
208
                string GetTypeFullName (object type);
 
209
                
 
210
                /// <summary>
 
211
                /// Gets the assembly qualified name of a type
 
212
                /// </summary>
 
213
                /// <returns>
 
214
                /// The assembly qualified type name
 
215
                /// </returns>
 
216
                /// <param name='type'>
 
217
                /// A type
 
218
                /// </param>
 
219
                string GetTypeAssemblyQualifiedName (object type);
 
220
                
 
221
                /// <summary>
 
222
                /// Gets a list of all base types (including interfaces) of a type
 
223
                /// </summary>
 
224
                /// <returns>
 
225
                /// An enumeration of the full name of all base types of the type
 
226
                /// </returns>
 
227
                /// <param name='type'>
 
228
                /// A type
 
229
                /// </param>
 
230
                IEnumerable GetBaseTypeFullNameList (object type);
 
231
                
 
232
                /// <summary>
 
233
                /// Checks if a type is assignable to another type
 
234
                /// </summary>
 
235
                /// <returns>
 
236
                /// 'true' if the type is assignable
 
237
                /// </returns>
 
238
                /// <param name='baseType'>
 
239
                /// Expected base type.
 
240
                /// </param>
 
241
                /// <param name='type'>
 
242
                /// A type.
 
243
                /// </param>
 
244
                bool TypeIsAssignableFrom (object baseType, object type);
 
245
                
 
246
                /// <summary>
 
247
                /// Gets the fields of a type
 
248
                /// </summary>
 
249
                /// <returns>
 
250
                /// The fields.
 
251
                /// </returns>
 
252
                /// <param name='type'>
 
253
                /// A type
 
254
                /// </param>
 
255
                IEnumerable GetFields (object type);
 
256
                
 
257
                /// <summary>
 
258
                /// Gets the name of a field.
 
259
                /// </summary>
 
260
                /// <returns>
 
261
                /// The field name.
 
262
                /// </returns>
 
263
                /// <param name='field'>
 
264
                /// A field.
 
265
                /// </param>
 
266
                string GetFieldName (object field);
 
267
                
 
268
                /// <summary>
 
269
                /// Gets the full name of the type of a field
 
270
                /// </summary>
 
271
                /// <returns>
 
272
                /// The full type name
 
273
                /// </returns>
 
274
                /// <param name='field'>
 
275
                /// A field.
 
276
                /// </param>
 
277
                string GetFieldTypeFullName (object field);
 
278
        }
 
279
        
 
280
        /// <summary>
 
281
        /// Allows finding assemblies in the file system
 
282
        /// </summary>
 
283
        public interface IAssemblyLocator
 
284
        {
 
285
                /// <summary>
 
286
                /// Locates an assembly
 
287
                /// </summary>
 
288
                /// <returns>
 
289
                /// The full path to the assembly, or null if not found
 
290
                /// </returns>
 
291
                /// <param name='fullName'>
 
292
                /// Full name of the assembly
 
293
                /// </param>
 
294
                string GetAssemblyLocation (string fullName);
 
295
        }
 
296
        
 
297
        /// <summary>
 
298
        /// A custom attribute
 
299
        /// </summary>
 
300
        public class CustomAttribute: Dictionary<string,string>
 
301
        {
 
302
                string typeName;
 
303
                
 
304
                /// <summary>
 
305
                /// Full name of the type of the custom attribute
 
306
                /// </summary>
 
307
                public string TypeName {
 
308
                        get { return typeName; }
 
309
                        set { typeName = value; }
 
310
                }
 
311
        }
 
312
}