IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
RawModule.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009-2013 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
24using System;
25
27
28namespace IKVM.Reflection
29{
30
31 internal sealed class RawModule : IDisposable
32 {
33
34 readonly ModuleReader module;
35 readonly bool isManifestModule;
36 bool imported;
37
42 internal RawModule(ModuleReader module)
43 {
44 this.module = module;
45 this.isManifestModule = module.Assembly != null;
46 }
47
48 public string Location
49 {
50 get { return module.FullyQualifiedName; }
51 }
52
53 public bool IsManifestModule
54 {
55 get { return isManifestModule; }
56 }
57
58 public Guid ModuleVersionId
59 {
60 get { return module.ModuleVersionId; }
61 }
62
63 public string ImageRuntimeVersion
64 {
65 get { return module.__ImageRuntimeVersion; }
66 }
67
68 public int MDStreamVersion
69 {
70 get { return module.MDStreamVersion; }
71 }
72
73 void CheckManifestModule()
74 {
75 if (!IsManifestModule)
76 throw new BadImageFormatException("Module does not contain a manifest");
77 }
78
79 public AssemblyName GetAssemblyName()
80 {
81 CheckManifestModule();
82 return module.Assembly.GetName();
83 }
84
85 public AssemblyName[] GetReferencedAssemblies()
86 {
87 return module.__GetReferencedAssemblies();
88 }
89
90 public void Dispose()
91 {
92 if (!imported)
93 module.Dispose();
94 }
95
96 internal AssemblyReader ToAssembly()
97 {
98 if (imported)
99 throw new InvalidOperationException();
100
101 imported = true;
102 return (AssemblyReader)module.Assembly;
103 }
104
105 internal Module ToModule(Assembly assembly)
106 {
107 if (module.Assembly != null)
108 throw new InvalidOperationException();
109
110 imported = true;
111 module.SetAssembly(assembly);
112 return module;
113 }
114
115 }
116
117}
IKVM.Reflection.Module Module
IKVM.Reflection.Assembly Assembly
IKVM.Reflection.AssemblyName AssemblyName