本文整理汇总了C#中IMethod.GetTypeArguments方法的典型用法代码示例。如果您正苦于以下问题:C# IMethod.GetTypeArguments方法的具体用法?C# IMethod.GetTypeArguments怎么用?C# IMethod.GetTypeArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethod
的用法示例。
在下文中一共展示了IMethod.GetTypeArguments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsyncNewObject
public static Eval AsyncNewObject(Thread evalThread, IMethod constructor, Value[] constructorArguments)
{
ICorDebugType[] typeArgs = constructor.GetTypeArguments();
ICorDebugValue[] ctorArgs = ValuesAsCorDebug(constructorArguments);
return new Eval(
evalThread,
"New object: " + constructor.FullName,
delegate(Eval eval) {
eval.CorEval2.NewParameterizedObject(
constructor.ToCorFunction(),
(uint)typeArgs.Length, typeArgs,
(uint)ctorArgs.Length, ctorArgs);
}
);
}
示例2: MethodInvokeStarter
/// <exception cref="GetValueException"><c>GetValueException</c>.</exception>
static void MethodInvokeStarter(Eval eval, IMethod method, Value thisValue, Value[] args)
{
List<ICorDebugValue> corArgs = new List<ICorDebugValue>();
args = args ?? new Value[0];
if (args.Length != method.Parameters.Count) {
throw new GetValueException("Invalid parameter count");
}
if (!method.IsStatic) {
if (thisValue == null)
throw new GetValueException("'this' is null");
if (thisValue.IsNull)
throw new GetValueException("Null reference");
corArgs.Add(thisValue.CorValue);
}
for(int i = 0; i < args.Length; i++) {
Value arg = args[i];
IType paramType = method.Parameters[i].Type;
if (!arg.IsNull &&
arg.Type.GetDefinition() != null &&
paramType.GetDefinition() != null &&
!arg.Type.GetDefinition().IsDerivedFrom(paramType.GetDefinition())) {
throw new GetValueException("Inncorrect parameter type. Expected " + paramType.ToString());
}
// It is importatnt to pass the parameter in the correct form (boxed/unboxed)
if (paramType.IsReferenceType == true) {
if (!arg.IsReference)
throw new DebuggerException("Reference expected as method argument");
corArgs.Add(arg.CorValue);
} else {
corArgs.Add(arg.CorGenericValue); // Unbox
}
}
ICorDebugType[] genericArgs = method.GetTypeArguments();
eval.CorEval2.CallParameterizedFunction(
method.ToCorFunction(),
(uint)genericArgs.Length, genericArgs,
(uint)corArgs.Count, corArgs.ToArray()
);
}