IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ManifestResourceInfo.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009-2012 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*/
26
27namespace IKVM.Reflection
28{
29
30 internal sealed class ManifestResourceInfo
31 {
32
33 readonly ModuleReader module;
34 readonly int index;
35
41 internal ManifestResourceInfo(ModuleReader module, int index)
42 {
43 this.module = module;
44 this.index = index;
45 }
46
47 public ResourceAttributes __ResourceAttributes
48 {
49 get { return (ResourceAttributes)module.ManifestResourceTable.records[index].Flags; }
50 }
51
52 public int __Offset
53 {
54 get { return module.ManifestResourceTable.records[index].Offset; }
55 }
56
57 public ResourceLocation ResourceLocation
58 {
59 get
60 {
61 var implementation = module.ManifestResourceTable.records[index].Implementation;
62 if ((implementation >> 24) == AssemblyRefTable.Index)
63 {
64 var asm = ReferencedAssembly;
65 if (asm == null || asm.__IsMissing)
66 return ResourceLocation.ContainedInAnotherAssembly;
67
68 return asm.GetManifestResourceInfo(module.GetString(module.ManifestResourceTable.records[index].Name)).ResourceLocation | ResourceLocation.ContainedInAnotherAssembly;
69 }
70 else if ((implementation >> 24) == FileTable.Index)
71 {
72 if ((implementation & 0xFFFFFF) == 0)
73 return ResourceLocation.ContainedInManifestFile | ResourceLocation.Embedded;
74
75 return 0;
76 }
77 else
78 {
79 throw new BadImageFormatException();
80 }
81 }
82 }
83
84 public Assembly ReferencedAssembly
85 {
86 get
87 {
88 var implementation = module.ManifestResourceTable.records[index].Implementation;
89 if ((implementation >> 24) == AssemblyRefTable.Index)
90 return module.ResolveAssemblyRef((implementation & 0xFFFFFF) - 1);
91
92 return null;
93 }
94 }
95
96 public string FileName
97 {
98 get
99 {
100 var implementation = module.ManifestResourceTable.records[index].Implementation;
101 if ((implementation >> 24) == FileTable.Index)
102 {
103 if ((implementation & 0xFFFFFF) == 0)
104 return null;
105 else
106 return module.GetString(module.FileTable.records[(implementation & 0xFFFFFF) - 1].Name);
107 }
108
109 return null;
110 }
111 }
112
113 }
114
115}
IKVM.Reflection.Assembly Assembly