本文整理汇总了C#中System.Reflection.Emit.AssemblyBuilder.DefineDynamicModule方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyBuilder.DefineDynamicModule方法的具体用法?C# AssemblyBuilder.DefineDynamicModule怎么用?C# AssemblyBuilder.DefineDynamicModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.AssemblyBuilder
的用法示例。
在下文中一共展示了AssemblyBuilder.DefineDynamicModule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssemblyEmitter
public AssemblyEmitter( string assemblyName, bool canSave )
{
m_AssemblyName = assemblyName;
m_AppDomain = AppDomain.CurrentDomain;
m_AssemblyBuilder = m_AppDomain.DefineDynamicAssembly(
new AssemblyName( assemblyName ),
canSave ? AssemblyBuilderAccess.RunAndSave : AssemblyBuilderAccess.Run
);
if ( canSave )
{
m_ModuleBuilder = m_AssemblyBuilder.DefineDynamicModule(
assemblyName,
String.Format( "{0}.dll", assemblyName.ToLower() ),
false
);
}
else
{
m_ModuleBuilder = m_AssemblyBuilder.DefineDynamicModule(
assemblyName,
false
);
}
}
示例2: DefineDynamicModule
public ModuleBuilder DefineDynamicModule(AssemblyBuilder assemblyBuilder, string moduleName)
{
#if DEBUG
ModuleBuilder moduleBuilder =
assemblyBuilder.DefineDynamicModule(moduleName, string.Format("{0}.mod", moduleName), true);
#else
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(moduleName);
#endif
return moduleBuilder;
}
示例3: AssemblyBuilder
public AssemblyBuilder(bool canSave)
{
_canSave = canSave;
_name = "EnigmaDynamicEmit." + Guid.NewGuid().ToString("N");
var domain = AppDomain.CurrentDomain;
_assemblyBuilder = domain.DefineDynamicAssembly(new AssemblyName(_name), canSave ? AssemblyBuilderAccess.RunAndSave : AssemblyBuilderAccess.Run);
_module = canSave
? _assemblyBuilder.DefineDynamicModule(_name, _name + ".dll")
: _assemblyBuilder.DefineDynamicModule(_name);
}
示例4: ProjectionAssembly
public ProjectionAssembly(string name, ProjectionOptions options)
{
this.name = name;
assembly = AppDomain.CurrentDomain.DefineDynamicAssembly
(
new AssemblyName(name),
GetAssemblyAccess(options)
);
module = 0 == (options & ProjectionOptions.SaveAssemblies)
? assembly.DefineDynamicModule(name)
: assembly.DefineDynamicModule(name, FileName);
}
示例5: RuntimeDynamicModule
public RuntimeDynamicModule()
{
_assemblyName = new AssemblyName(DEFAULT_MODULE_NAME);
_assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(_assemblyName,
AssemblyBuilderAccess.RunAndSave);
_moduleBuilder = _assemblyBuilder.DefineDynamicModule(DEFAULT_MODULE_NAME, DEFAULT_MODULE_NAME + ".dll");
}
示例6: WrapFactory
/// <summary>
/// A static constructor.
/// </summary>
static WrapFactory()
{
AssemblyName asmName = new AssemblyName();
asmName.Name = "SqlWrapperDynamicAsm";
m_asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(asmName, AssemblyBuilderAccess.RunAndSave);
m_modBuilder = m_asmBuilder.DefineDynamicModule("SqlWrapperDynamicModule");
}
示例7: ObjCMethod
static ObjCMethod()
{
AssemblyName name = new AssemblyName ();
name.Name = "MethodProxies";
builder = AppDomain.CurrentDomain.DefineDynamicAssembly (name, AssemblyBuilderAccess.Run, null, null, null, null, null, true);
module = builder.DefineDynamicModule ("Proxies");
}
示例8: SetAccessorFactory
/// <summary>
/// Initializes a new instance of the <see cref="SetAccessorFactory"/> class.
/// </summary>
/// <param name="allowCodeGeneration">if set to <c>true</c> [allow code generation].</param>
public SetAccessorFactory(bool allowCodeGeneration)
{
if (allowCodeGeneration)
{
// Detect runtime environment and create the appropriate factory
if (Environment.Version.Major >= 2)
{
_createPropertySetAccessor = new CreatePropertySetAccessor(CreateDynamicPropertySetAccessor);
_createFieldSetAccessor = new CreateFieldSetAccessor(CreateDynamicFieldSetAccessor);
}
else
{
AssemblyName assemblyName = new AssemblyName();
assemblyName.Name = "iBATIS.FastSetAccessor" + HashCodeProvider.GetIdentityHashCode(this);
// Create a new assembly with one module
_assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
_moduleBuilder = _assemblyBuilder.DefineDynamicModule(assemblyName.Name + ".dll");
_createPropertySetAccessor = new CreatePropertySetAccessor(CreatePropertyAccessor);
_createFieldSetAccessor = new CreateFieldSetAccessor(CreateFieldAccessor);
}
}
else
{
_createPropertySetAccessor = new CreatePropertySetAccessor(CreateReflectionPropertySetAccessor);
_createFieldSetAccessor = new CreateFieldSetAccessor(CreateReflectionFieldSetAccessor);
}
}
示例9: NativeDelegateServices
static NativeDelegateServices()
{
var name = new AssemblyName {Name = "NativeDelegateWrapperAssembly"};
asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run);
moduleBuilder = asmBuilder.DefineDynamicModule("NativeDelegateWrapperModule");
wrapperCache = new Dictionary<KeyValuePair<Type, IntPtr>, Type>();
}
示例10: DynamicAssemblyManager
static DynamicAssemblyManager()
{
#if !SILVERLIGHT
assemblyName = new AssemblyName("NLiteDynamicAssembly");
assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
assemblyName,
AssemblyBuilderAccess.RunAndSave
);
moduleBuilder = assemblyBuilder.DefineDynamicModule(
assemblyName.Name,
assemblyName.Name + ".dll",
true);
Module = assemblyBuilder.GetModules().FirstOrDefault();
#else
assemblyName = new AssemblyName("EmitMapperAssembly.SL");
assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
assemblyName,
AssemblyBuilderAccess.Run
);
moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, true);
#endif
}
示例11: GenContext
public GenContext(string assyName, string directory, CompilerMode mode)
{
AssemblyName aname = new AssemblyName(assyName);
_assyBldr = AppDomain.CurrentDomain.DefineDynamicAssembly(aname, AssemblyBuilderAccess.RunAndSave,directory);
_moduleBldr = _assyBldr.DefineDynamicModule(aname.Name, aname.Name + ".dll", true);
_mode = mode;
}
示例12: CreateAssembly
private void CreateAssembly()
{ //to create an assembly programmatically
AssemblyName Name = new AssemblyName("NaiveORM0Classes");
AppDomain Domain = Thread.GetDomain();
_Builder = Domain.DefineDynamicAssembly(Name, AssemblyBuilderAccess.Run);
_Module = _Builder.DefineDynamicModule("NaiveORM0ClassesM");
}
示例13: DynamicAssembly
public DynamicAssembly()
{
int assemblyNumber = Interlocked.Increment(ref _assemblyCount);
_assemblyName = new AssemblyName {
Name = String.Format("Quokka.DynamicAssembly.N{0}", assemblyNumber)
};
string moduleName = AssemblyName.Name;
_dynamicClassNamespace = AssemblyName.Name;
if (CreateFiles)
{
_assemblyBuilder = Thread.GetDomain().DefineDynamicAssembly(
AssemblyName, AssemblyBuilderAccess.RunAndSave);
// Add a debuggable attribute to the assembly saying to disable optimizations
// See http://blogs.msdn.com/rmbyers/archive/2005/06/26/432922.aspx
Type daType = typeof (DebuggableAttribute);
ConstructorInfo daCtor = daType.GetConstructor(new[] {typeof (bool), typeof (bool)});
var daBuilder = new CustomAttributeBuilder(daCtor, new object[] {true, true});
_assemblyBuilder.SetCustomAttribute(daBuilder);
_moduleBuilder = _assemblyBuilder.DefineDynamicModule(moduleName);
_canSave = true;
}
else
{
_assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess.Run);
_moduleBuilder = _assemblyBuilder.DefineDynamicModule(moduleName);
}
}
示例14: Reset
public void Reset()
{
UniqueCounter++;
var CurrentAppDomain = AppDomain.CurrentDomain;
AssemblyBuilder = CurrentAppDomain.DefineDynamicAssembly(new AssemblyName("assembly" + UniqueCounter), AssemblyBuilderAccess.RunAndSave);
ModuleBuilder = AssemblyBuilder.DefineDynamicModule("module" + UniqueCounter);
}
示例15: FixtureSetUp
public void FixtureSetUp()
{
//assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("TestAssembly"), AssemblyBuilderAccess.RunAndSave);
//moduleBuilder = assemblyBuilder.DefineDynamicModule("TestAssembly", "TestAssembly.dll");
assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("TestAssembly"), AssemblyBuilderAccess.Run);
moduleBuilder = assemblyBuilder.DefineDynamicModule("TestAssembly");
}