本文整理汇总了C#中System.Reflection.Emit.AssemblyBuilder.CreateInstance方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyBuilder.CreateInstance方法的具体用法?C# AssemblyBuilder.CreateInstance怎么用?C# AssemblyBuilder.CreateInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.AssemblyBuilder
的用法示例。
在下文中一共展示了AssemblyBuilder.CreateInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitIL
/// <summary>
/// This method create a new type oject for the the property accessor class
/// that will provide dynamic access.
/// </summary>
/// <param name="assemblyBuilder">The assembly builder.</param>
/// <param name="moduleBuilder">The module builder.</param>
private void EmitIL(AssemblyBuilder assemblyBuilder, ModuleBuilder moduleBuilder)
{
// Create a new type object for the the field accessor class.
EmitType(moduleBuilder);
// Create a new instance
_emittedSet = assemblyBuilder.CreateInstance("SetFor" + _targetType.FullName + _propertyName) as ISet;
nullInternal = GetNullInternal(_propertyType);
if (_emittedSet == null)
{
throw new NotSupportedException(
string.Format("Unable to create a get propert accessor for '{0}' property on class '{1}'.", _propertyName, _propertyType));
}
}
示例2: EmitIL
private void EmitIL(AssemblyBuilder assemblyBuilder, ModuleBuilder moduleBuilder)
{
// Create a new type object for the the field accessor class.
EmitType(moduleBuilder);
// Create a new instance
_emittedSetter = assemblyBuilder.CreateInstance("SetFor" + _targetType.FullName + _fieldName) as ISetter;
this.nullInternal = this.GetNullInternal(_fieldType);
if (_emittedSetter == null)
{
throw new NotSupportedException(
string.Format("Unable to create a set field accessor for '{0}' field on class '{0}'.", _fieldName, _fieldType));
}
}