本文整理汇总了C#中ModuleBuilder类的典型用法代码示例。如果您正苦于以下问题:C# ModuleBuilder类的具体用法?C# ModuleBuilder怎么用?C# ModuleBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModuleBuilder类属于命名空间,在下文中一共展示了ModuleBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TextSection
internal TextSection(PEWriter peWriter, CliHeader cliHeader, ModuleBuilder moduleBuilder, bool strongName)
{
this.peWriter = peWriter;
this.cliHeader = cliHeader;
this.moduleBuilder = moduleBuilder;
this.strongName = strongName;
}
示例2: TextSection
internal TextSection(PEWriter peWriter, CliHeader cliHeader, ModuleBuilder moduleBuilder, int strongNameSignatureLength)
{
this.peWriter = peWriter;
this.cliHeader = cliHeader;
this.moduleBuilder = moduleBuilder;
this.strongNameSignatureLength = (uint)strongNameSignatureLength;
}
示例3: WriteModule
internal static void WriteModule(StrongNameKeyPair keyPair, byte[] publicKey, ModuleBuilder moduleBuilder,
PEFileKinds fileKind, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine,
ResourceSection resources, int entryPointToken, Stream stream)
{
if (stream == null)
{
string fileName = moduleBuilder.FullyQualifiedName;
bool mono = System.Type.GetType("Mono.Runtime") != null;
if (mono)
{
try
{
// Mono mmaps the file, so unlink the previous version since it may be in use
File.Delete(fileName);
}
catch { }
}
using (FileStream fs = new FileStream(fileName, FileMode.Create))
{
WriteModuleImpl(keyPair, publicKey, moduleBuilder, fileKind, portableExecutableKind, imageFileMachine, resources, entryPointToken, fs);
}
// if we're running on Mono, mark the module as executable by using a Mono private API extension
if (mono)
{
File.SetAttributes(fileName, (FileAttributes)(unchecked((int)0x80000000)));
}
}
else
{
WriteModuleImpl(keyPair, publicKey, moduleBuilder, fileKind, portableExecutableKind, imageFileMachine, resources, entryPointToken, stream);
}
}
示例4: ParameterBuilder
internal ParameterBuilder(ModuleBuilder moduleBuilder, int sequence, ParameterAttributes attribs, string name)
{
this.moduleBuilder = moduleBuilder;
this.flags = (short)attribs;
this.sequence = (short)sequence;
this.nameIndex = name == null ? 0 : moduleBuilder.Strings.Add(name);
this.name = name;
}
示例5: ModuleScope
/// <summary>
/// 构建一个可保存的动态程序集 ModuleScope 模块
/// </summary>
/// <param name="assemblySaveDir">程序集保存的目录</param>
public ModuleScope(String assemblySaveDir)
{
if (assemblySaveDir != null && !Directory.Exists(assemblySaveDir))
{
throw new DirectoryNotFoundException(assemblySaveDir);
}
_assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(NameOfAssembly), AssemblyBuilderAccess.RunAndSave, assemblySaveDir);
ModuleBuilder = _assemblyBuilder.DefineDynamicModule(NameOfAssembly, AssemblyFileName);
SavePhysicalAssembly = true;
}
示例6: TextSection
internal TextSection(PEWriter peWriter, CliHeader cliHeader, ModuleBuilder moduleBuilder, int strongNameSignatureLength)
{
this.peWriter = peWriter;
this.cliHeader = cliHeader;
this.moduleBuilder = moduleBuilder;
this.strongNameSignatureLength = (uint)strongNameSignatureLength;
if (moduleBuilder.unmanagedExports.Count != 0)
{
this.exportTables = new ExportTables(this);
}
}
示例7: Create
internal static void Create(ModuleBuilder modb, ClassLoaderWrapper loader)
{
TypeBuilder tb = modb.DefineType(DotNetTypeWrapper.GenericDelegateInterfaceTypeName, TypeAttributes.Interface | TypeAttributes.Abstract | TypeAttributes.Public);
tb.DefineGenericParameters("T")[0].SetBaseTypeConstraint(Types.MulticastDelegate);
genericDelegateInterfaceType = tb.CreateType();
genericAttributeAnnotationType = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationTypeName);
genericAttributeAnnotationMultipleType = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationMultipleTypeName);
genericAttributeAnnotationReturnValueType = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationReturnValueTypeName);
CreateEnumEnum(modb, loader);
}
示例8: CreateEnumEnum
private static void CreateEnumEnum(ModuleBuilder modb, ClassLoaderWrapper loader)
{
TypeWrapper enumTypeWrapper = loader.LoadClassByDottedName("java.lang.Enum");
enumTypeWrapper.Finish();
TypeBuilder tb = modb.DefineType(DotNetTypeWrapper.GenericEnumEnumTypeName, TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public, enumTypeWrapper.TypeAsBaseType);
GenericTypeParameterBuilder gtpb = tb.DefineGenericParameters("T")[0];
gtpb.SetBaseTypeConstraint(Types.Enum);
CodeEmitter ilgen = CodeEmitter.Create(tb.DefineConstructor(MethodAttributes.Private, CallingConventions.Standard, new Type[] { Types.String, Types.Int32 }));
ilgen.Emit(OpCodes.Ldarg_0);
ilgen.Emit(OpCodes.Ldarg_1);
ilgen.Emit(OpCodes.Ldarg_2);
enumTypeWrapper.GetMethodWrapper("<init>", "(Ljava.lang.String;I)V", false).EmitCall(ilgen);
ilgen.Emit(OpCodes.Ret);
genericEnumEnumType = tb.CreateType();
}
示例9: CreateSymbolWriterFor
internal static ISymbolWriterImpl CreateSymbolWriterFor(ModuleBuilder moduleBuilder)
{
if (runningOnMono)
{
#if MONO
return new MdbWriter(moduleBuilder);
#else
throw new NotSupportedException("IKVM.Reflection must be compiled with MONO defined to support writing Mono debugging symbols.");
#endif
}
else
{
return new PdbWriter(moduleBuilder);
}
}
示例10: RouteResolver
public RouteResolver(
ModuleCatalog catalog,
ModuleBuilder moduleBuilder,
RouteResolverTrie routeTrie)
{
if (catalog == null)
throw new ArgumentNullException("catalog");
if (moduleBuilder == null)
throw new ArgumentNullException("moduleBuilder");
if (routeTrie == null)
throw new ArgumentNullException("routeTrie");
_catalog = catalog;
_moduleBuilder = moduleBuilder;
_routeTrie = routeTrie;
}
示例11: WriteModule
internal static void WriteModule(StrongNameKeyPair keyPair, byte[] publicKey, ModuleBuilder moduleBuilder,
PEFileKinds fileKind, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine,
ResourceSection resources, int entryPointToken, Stream stream)
{
if (stream == null)
{
using (FileStream fs = new FileStream(moduleBuilder.FullyQualifiedName, FileMode.Create))
{
WriteModuleImpl(keyPair, publicKey, moduleBuilder, fileKind, portableExecutableKind, imageFileMachine, resources, entryPointToken, fs);
}
}
else
{
WriteModuleImpl(keyPair, publicKey, moduleBuilder, fileKind, portableExecutableKind, imageFileMachine, resources, entryPointToken, stream);
}
}
示例12: CreateSymbolWriterFor
internal static ISymbolWriterImpl CreateSymbolWriterFor(ModuleBuilder moduleBuilder)
{
#if NO_SYMBOL_WRITER
throw new NotSupportedException("IKVM.Reflection compiled with NO_SYMBOL_WRITER does not support writing debugging symbols.");
#else
if (Universe.MonoRuntime)
{
#if MONO
return new MdbWriter(moduleBuilder);
#else
throw new NotSupportedException("IKVM.Reflection must be compiled with MONO defined to support writing Mono debugging symbols.");
#endif
}
else
{
return new PdbWriter(moduleBuilder);
}
#endif
}
示例13: WriteModule
internal static void WriteModule(StrongNameKeyPair keyPair, byte[] publicKey, ModuleBuilder moduleBuilder,
PEFileKinds fileKind, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine,
ResourceSection resources, int entryPointToken, Stream stream)
{
if (stream == null)
{
using (FileStream fs = new FileStream(moduleBuilder.FullyQualifiedName, FileMode.Create))
{
WriteModuleImpl(keyPair, publicKey, moduleBuilder, fileKind, portableExecutableKind, imageFileMachine, resources, entryPointToken, fs);
}
// if we're running on Mono, mark the module as executable by using a Mono private API extension
if (System.Type.GetType("Mono.Runtime") != null)
{
File.SetAttributes(moduleBuilder.FullyQualifiedName, (FileAttributes)(unchecked((int)0x80000000)));
}
}
else
{
WriteModuleImpl(keyPair, publicKey, moduleBuilder, fileKind, portableExecutableKind, imageFileMachine, resources, entryPointToken, stream);
}
}
示例14: CreateAnnotationType
private static Type CreateAnnotationType(ModuleBuilder modb, string name)
{
TypeBuilder tb = modb.DefineType(name, TypeAttributes.Interface | TypeAttributes.Abstract | TypeAttributes.Public);
tb.DefineGenericParameters("T")[0].SetBaseTypeConstraint(Types.Attribute);
return tb.CreateType();
}
示例15: ImportTo
internal override int ImportTo(ModuleBuilder module)
{
return module.ImportMember(methodBuilder);
}