本文整理汇总了C#中ModuleDefinition类的典型用法代码示例。如果您正苦于以下问题:C# ModuleDefinition类的具体用法?C# ModuleDefinition怎么用?C# ModuleDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModuleDefinition类属于命名空间,在下文中一共展示了ModuleDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSymbolReader
public ISymbolReader GetSymbolReader(ModuleDefinition module, Stream symbolStream)
{
Mixin.CheckModule (module);
Mixin.CheckStream (symbolStream);
return new PdbReader (Disposable.NotOwned (symbolStream));
}
示例2: GetClrBasicsFor
private static ModuleDefinition GetClrBasicsFor(string file, PEFile pe)
{
var stream = new MemoryStream(File.ReadAllBytes(file));
var reader = new BinaryStreamReader(stream, new byte[1024]);
pe.ReadFrom(reader);
var clrDirectory = pe.OptionalHeader.DataDirectories[(int)DataDirectoryKind.Clr];
var rvaStream = new RvaStream(
stream,
pe.SectionHeaders.Select(
s => new RvaStream.Range
{
PhysicalAddress = s.PointerToRawData,
Size = s.VirtualSize,
VirtualAddress = s.VirtualAddress
})
.ToArray());
rvaStream.Position = clrDirectory.VirtualAddress;
var sectionReader = new BinaryStreamReader(rvaStream, new byte[32]);
var clrmod = new ModuleDefinition();
ClrModuleReader.Read(sectionReader, clrmod);
return clrmod;
}
示例3: GetSchemaFromModuleAsync
public async Task<JSchema> GetSchemaFromModuleAsync(ModuleDefinition module)
{
IEnumerable<TemplateInfo> templates;
if (module.Skins != null)
templates = module.Skins.Values;
else
templates = Enumerable.Empty<TemplateInfo>();
if (module.DefaultTemplate != null)
templates = templates.Union(new[] {module.DefaultTemplate});
var enumerator = templates.GetEnumerator();
if (!enumerator.MoveNext())
return null;
var result = await _schemaProvider.GetSchemaFromTemplateAsync(enumerator.Current).ConfigureAwait(false);
var report = new SchemaComparisionReport();
while (enumerator.MoveNext())
{
var schema = await _schemaProvider.GetSchemaFromTemplateAsync(enumerator.Current).ConfigureAwait(false);
result = _schemaCombiner.Apply(result, schema, report);
}
return result;
}
示例4: PdbWriter
internal PdbWriter(ISymbolWriter writer, ModuleDefinition module, string pdb)
{
m_writer = writer;
m_module = module;
m_documents = new Hashtable ();
m_pdb = pdb;
}
示例5: ReadModule
public virtual void ReadModule()
{
string symbolsPath;
if (pdbFound)
{
symbolsPath = pdbPath;
}
else
{
symbolsPath = mdbPath;
}
var tempAssembly = $"{AssemblyFilePath}.tmp";
var tempSymbols = $"{symbolsPath}.tmp";
File.Copy(AssemblyFilePath, tempAssembly,true);
File.Copy(symbolsPath, tempSymbols, true);
SymbolStream = File.OpenRead(tempSymbols);
var readerParameters = new ReaderParameters
{
AssemblyResolver = this,
ReadSymbols = true,
SymbolReaderProvider = debugReaderProvider,
SymbolStream = SymbolStream,
};
ModuleDefinition = ModuleDefinition.ReadModule(tempAssembly, readerParameters);
}
示例6: TestUseCombinedSkinsSchemaWhenNoDefaultTemplate
public void TestUseCombinedSkinsSchemaWhenNoDefaultTemplate()
{
var templateInfo = new StringTemplateInfo("test", "");
var templateInfo2 = new StringTemplateInfo("test2", "");
var schema1 = new JSchema();
var schema2 = new JSchema();
var templateSchemaProvider = new Mock<ISchemaProvider>();
templateSchemaProvider.Setup(f => f.GetSchemaFromTemplateAsync(templateInfo)).Returns(Task.FromResult(schema1));
templateSchemaProvider.Setup(f => f.GetSchemaFromTemplateAsync(templateInfo2)).Returns(Task.FromResult(schema2));
var combiner = new Mock<SchemaCombiner>();
combiner.Setup(c =>
c.Apply(It.Is<JSchema>(s => s == schema1), It.Is<JSchema>(s => s == schema2), It.IsAny<SchemaComparisionReport>(), It.IsAny<string>()))
.Returns(new JSchema());
var moduleDefintion = new ModuleDefinition("testmod", null, new Dictionary<string, TemplateInfo>
{
{"skin1", templateInfo},
{"skin2", templateInfo2}
});
var underTest = new DefaultModuleSchemaProvider(combiner.Object, templateSchemaProvider.Object);
var result = underTest.GetSchemaFromModuleAsync(moduleDefintion);
Assert.IsNotNull(result);
combiner.Verify();
}
示例7: OtherMethod
public void OtherMethod(ModuleDefinition module)
{
var type = module.GetType ("Others");
Assert.IsTrue (type.HasProperties);
var properties = type.Properties;
Assert.AreEqual (1, properties.Count);
var property = properties [0];
Assert.IsNotNull (property);
Assert.AreEqual ("Context", property.Name);
Assert.IsNotNull (property.PropertyType);
Assert.AreEqual ("System.String", property.PropertyType.FullName);
Assert.IsTrue (property.HasOtherMethods);
Assert.AreEqual (2, property.OtherMethods.Count);
var other = property.OtherMethods [0];
Assert.AreEqual ("let_Context", other.Name);
other = property.OtherMethods [1];
Assert.AreEqual ("bet_Context", other.Name);
}
示例8: RefinementToken
public RefinementToken(IToken tok, ModuleDefinition m)
: base(tok)
{
Contract.Requires(tok != null);
Contract.Requires(m != null);
this.InheritingModule = m;
}
示例9: CreateDebugWriter
public static ImageWriter CreateDebugWriter(ModuleDefinition module, MetadataBuilder metadata, Disposable<Stream> stream)
{
var writer = new ImageWriter (module, "PDB V1.0", metadata, stream, metadataOnly: true);
var length = metadata.text_map.GetLength ();
writer.text = new Section { SizeOfRawData = length, VirtualSize = length };
return writer;
}
示例10: ReadModule
public void ReadModule()
{
if (pdbFound)
{
using (var symbolStream = File.OpenRead(pdbPath))
{
var readerParameters = new ReaderParameters
{
AssemblyResolver = this,
ReadSymbols = pdbFound || mdbFound,
SymbolReaderProvider = debugReaderProvider,
SymbolStream = symbolStream
};
ModuleDefinition = ModuleDefinition.ReadModule(AssemblyFilePath, readerParameters);
}
}
else
{
var readerParameters = new ReaderParameters
{
AssemblyResolver = this,
ReadSymbols = pdbFound || mdbFound,
SymbolReaderProvider = debugReaderProvider,
};
ModuleDefinition = ModuleDefinition.ReadModule(AssemblyFilePath, readerParameters);
}
}
示例11: ReflectionController
public ReflectionController (ModuleDefinition module)
{
m_reader = new AggressiveReflectionReader (module);
m_writer = new ReflectionWriter (module);
m_helper = new ReflectionHelper (module);
m_importer = new DefaultImporter (module);
}
示例12: ReplaceTokens
public string ReplaceTokens(string template, ModuleDefinition moduleDefinition, Repository repo, string changestring)
{
var assemblyVersion = moduleDefinition.Assembly.Name.Version;
var branch = repo.Head;
template = template.Replace("%version%", assemblyVersion.ToString());
template = template.Replace("%version1%", assemblyVersion.ToString(1));
template = template.Replace("%version2%", assemblyVersion.ToString(2));
template = template.Replace("%version3%", assemblyVersion.ToString(3));
template = template.Replace("%version4%", assemblyVersion.ToString(4));
template = template.Replace("%now%", now.ToShortDateString());
template = template.Replace("%utcnow%", utcNow.ToShortDateString());
template = template.Replace("%githash%", branch.Tip.Sha);
template = template.Replace("%shorthash%", branch.Tip.Sha.Substring(0, 8));
template = template.Replace("%branch%", branch.FriendlyName);
template = template.Replace("%haschanges%", repo.IsClean() ? "" : changestring);
template = template.Replace("%user%", FormatUserName());
template = template.Replace("%machine%", Environment.MachineName);
template = reEnvironmentToken.Replace(template, FormatEnvironmentVariable);
template = reNow.Replace(template, FormatTime);
template = reUtcNow.Replace(template, FormatUtcTime);
return template.Trim();
}
示例13: Main
public void Main (ModuleDefinition module)
{
var type = module.GetType ("Program");
var main = type.GetMethod ("Main");
AssertCode (@"
.locals init (System.Int32 i)
.line 7,7:0,0 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
IL_0000: ldc.i4.0
IL_0001: stloc.0
.line 7,7:0,0 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
IL_0002: br IL_0013
.line 8,8:0,0 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
IL_0007: ldarg.0
IL_0008: ldloc.0
IL_0009: ldelem.ref
IL_000a: call System.Void Program::Print(System.String)
.line 7,7:0,0 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
IL_000f: ldloc.0
IL_0010: ldc.i4.1
IL_0011: add
IL_0012: stloc.0
IL_0013: ldloc.0
IL_0014: ldarg.0
IL_0015: ldlen
IL_0016: conv.i4
IL_0017: blt IL_0007
.line 10,10:0,0 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
IL_001c: ldc.i4.0
IL_001d: ret
", main);
}
示例14: PdbWriter
internal PdbWriter (SymWriter writer, ModuleDefinition module, string assembly)
{
m_writer = writer;
m_module = module;
m_documents = new Hashtable ();
m_assembly = assembly;
}
示例15: PortablePdbReader
internal PortablePdbReader(Image image, ModuleDefinition module)
{
this.image = image;
this.module = module;
this.reader = module.reader;
this.debug_reader = new MetadataReader (image, module, this.reader);
}