1 | // |
---|
2 | // AssemblyLoader.cs |
---|
3 | // |
---|
4 | // Author: |
---|
5 | // Mike KrÃŒger <mkrueger@xamarin.com> |
---|
6 | // |
---|
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com) |
---|
8 | // |
---|
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
10 | // of this software and associated documentation files (the "Software"), to deal |
---|
11 | // in the Software without restriction, including without limitation the rights |
---|
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
13 | // copies of the Software, and to permit persons to whom the Software is |
---|
14 | // furnished to do so, subject to the following conditions: |
---|
15 | // |
---|
16 | // The above copyright notice and this permission notice shall be included in |
---|
17 | // all copies or substantial portions of the Software. |
---|
18 | // |
---|
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
25 | // THE SOFTWARE. |
---|
26 | using System; |
---|
27 | using System.Reflection; |
---|
28 | using System.Threading; |
---|
29 | using ICSharpCode.NRefactory.Documentation; |
---|
30 | using ICSharpCode.NRefactory.TypeSystem; |
---|
31 | using ICSharpCode.NRefactory.TypeSystem.Implementation; |
---|
32 | |
---|
33 | namespace ICSharpCode.NRefactory.TypeSystem |
---|
34 | { |
---|
35 | public enum AssemblyLoaderBackend { |
---|
36 | Auto, |
---|
37 | Cecil, |
---|
38 | IKVM |
---|
39 | } |
---|
40 | |
---|
41 | public abstract class AssemblyLoader |
---|
42 | { |
---|
43 | public static AssemblyLoader Create () |
---|
44 | { |
---|
45 | return Create (AssemblyLoaderBackend.Auto); |
---|
46 | } |
---|
47 | |
---|
48 | public static AssemblyLoader Create (AssemblyLoaderBackend backend) |
---|
49 | { |
---|
50 | switch (backend) { |
---|
51 | case AssemblyLoaderBackend.Auto: |
---|
52 | case AssemblyLoaderBackend.Cecil: |
---|
53 | return (AssemblyLoader)Assembly.Load ("ICSharpCode.NRefactory.Cecil").CreateInstance ("ICSharpCode.NRefactory.TypeSystem.CecilLoader"); |
---|
54 | case AssemblyLoaderBackend.IKVM: |
---|
55 | return (AssemblyLoader)Assembly.Load ("ICSharpCode.NRefactory.IKVM").CreateInstance ("ICSharpCode.NRefactory.TypeSystem.IkvmLoader"); |
---|
56 | default: |
---|
57 | throw new ArgumentOutOfRangeException (); |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | /// <summary> |
---|
62 | /// Specifies whether to include internal members. The default is false. |
---|
63 | /// </summary> |
---|
64 | public bool IncludeInternalMembers { get; set; } |
---|
65 | |
---|
66 | /// <summary> |
---|
67 | /// Gets/Sets the cancellation token used by the assembly loader. |
---|
68 | /// </summary> |
---|
69 | public CancellationToken CancellationToken { get; set; } |
---|
70 | |
---|
71 | /// <summary> |
---|
72 | /// Gets/Sets the documentation provider that is used to retrieve the XML documentation for all members. |
---|
73 | /// </summary> |
---|
74 | public IDocumentationProvider DocumentationProvider { get; set; } |
---|
75 | |
---|
76 | [CLSCompliant(false)] |
---|
77 | protected InterningProvider interningProvider = new SimpleInterningProvider(); |
---|
78 | |
---|
79 | /// <summary> |
---|
80 | /// Gets/Sets the interning provider. |
---|
81 | /// </summary> |
---|
82 | public InterningProvider InterningProvider { |
---|
83 | get { return interningProvider; } |
---|
84 | set { |
---|
85 | if (value == null) |
---|
86 | throw new ArgumentNullException(); |
---|
87 | interningProvider = value; |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | public abstract IUnresolvedAssembly LoadAssemblyFile(string fileName); |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|