本文整理汇总了C#中TypeReference.Read方法的典型用法代码示例。如果您正苦于以下问题:C# TypeReference.Read方法的具体用法?C# TypeReference.Read怎么用?C# TypeReference.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeReference
的用法示例。
在下文中一共展示了TypeReference.Read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadModule
public static ChelaModule LoadModule(ModuleReader reader, bool fullLoad)
{
// Try to guess the file type.
uint moduleStart = reader.GetPosition();
byte[] signature;
reader.Read(out signature, 8);
// Check for elf file type.
bool isElf = true;
for(int i = 0; i < 4; ++i)
{
if(signature[i] != ElfFormat.ElfMagic[i])
{
isElf = false;
break;
}
}
// Check for PE.
bool isPE = signature[0] == 'M' && signature[1] == 'Z';
// Find the module content.
reader.SetPosition(moduleStart);
if(isElf)
{
// Move to the embedded module.
ElfFormat.GetEmbeddedModule(reader);
reader.FixBase();
}
else if(isPE)
{
// Move to the embedded module.
PEFormat.GetEmbeddedModule(reader);
reader.FixBase();
}
// Read the module header.
ModuleHeader header = new ModuleHeader();
header.Read(reader);
// Create the output module.
ChelaModule result = new ChelaModule();
// Read the string table.
reader.SetPosition(header.stringTableOffset);
for(uint i = 0; i < header.stringTableEntries; ++i)
{
uint id = i+1u;
string s = reader.ReadString();
result.stringTable.Add(s);
result.registeredStrings.Add(s, id);
}
// Read myself data.
ModuleReference modref = new ModuleReference();
reader.SetPosition(header.moduleRefTableOffset);
modref.Read(reader);
result.SetName(result.GetString(modref.moduleName));
// Read the module type.
result.moduleType = (ModuleType)header.moduleType;
// Read the referenced modules.
for(uint i = 1; i < header.moduleRefTableEntries; ++i)
{
// Read the referenced module.
modref.Read(reader);
// Load it.
ChelaModule referencedModule = LoadNamedModule(result.GetString(modref.moduleName));
result.referencedModules.Add(referencedModule);
}
// Preload the members.
reader.SetPosition(header.memberTableOffset);
uint end = header.memberTableOffset + header.memberTableSize;
MemberHeader mheader = new MemberHeader();
while(reader.GetPosition() < end)
{
// Read the member header.
mheader.Read(reader);
// Skip the attributes.
SkipAttributes(reader, mheader.memberAttributes);
// Preload the member.
MemberHeaderType mtype = (MemberHeaderType)mheader.memberType;
switch(mtype)
{
case MemberHeaderType.Namespace:
Namespace.PreloadMember(result, reader, mheader);
break;
case MemberHeaderType.Structure:
Structure.PreloadMember(result, reader, mheader);
break;
case MemberHeaderType.Class:
Class.PreloadMember(result, reader, mheader);
break;
case MemberHeaderType.Interface:
Interface.PreloadMember(result, reader, mheader);
//.........这里部分代码省略.........