本文整理汇总了C#中System.Reflection.Emit.TypeBuilder.CreateTypeInfo方法的典型用法代码示例。如果您正苦于以下问题:C# TypeBuilder.CreateTypeInfo方法的具体用法?C# TypeBuilder.CreateTypeInfo怎么用?C# TypeBuilder.CreateTypeInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.TypeBuilder
的用法示例。
在下文中一共展示了TypeBuilder.CreateTypeInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyMethodSignature
private void VerifyMethodSignature(TypeBuilder typeBuilder, MethodBuilder builder, Type desiredReturnType)
{
Type ret = typeBuilder.CreateTypeInfo().AsType();
MethodInfo methodInfo = builder.GetBaseDefinition();
Type actualReturnType = methodInfo.ReturnType;
if (desiredReturnType == null)
Assert.Null(actualReturnType);
if (desiredReturnType != null)
{
Assert.NotNull(actualReturnType);
Assert.Equal(desiredReturnType.Name, actualReturnType.Name);
Assert.True(actualReturnType.Equals(desiredReturnType));
}
}
示例2: OrElse_NoMethod_TrueOperatorIncorrectMethod_ThrowsArgumentException
public static void OrElse_NoMethod_TrueOperatorIncorrectMethod_ThrowsArgumentException(TypeBuilder builder, Type returnType, Type[] parameterTypes)
{
MethodBuilder opTrue = builder.DefineMethod("op_True", MethodAttributes.SpecialName | MethodAttributes.Static, returnType, parameterTypes);
opTrue.GetILGenerator().Emit(OpCodes.Ret);
MethodBuilder opFalse = builder.DefineMethod("op_False", MethodAttributes.SpecialName | MethodAttributes.Static, typeof(bool), new Type[] { builder.AsType() });
opFalse.GetILGenerator().Emit(OpCodes.Ret);
MethodBuilder method = builder.DefineMethod("op_BitwiseOr", MethodAttributes.Public | MethodAttributes.Static, builder.AsType(), new Type[] { builder.AsType(), builder.AsType() });
method.GetILGenerator().Emit(OpCodes.Ret);
TypeInfo createdType = builder.CreateTypeInfo();
object obj = Activator.CreateInstance(createdType.AsType());
Assert.Throws<ArgumentException>(null, () => Expression.OrElse(Expression.Constant(obj), Expression.Constant(obj)));
}