本文整理汇总了C#中Mono.Debugger.Soft.MethodMirror.Evaluate方法的典型用法代码示例。如果您正苦于以下问题:C# MethodMirror.Evaluate方法的具体用法?C# MethodMirror.Evaluate怎么用?C# MethodMirror.Evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Debugger.Soft.MethodMirror
的用法示例。
在下文中一共展示了MethodMirror.Evaluate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RuntimeInvoke
public Value RuntimeInvoke (MethodMirror method, object target, Value[] values)
{
if (values != null) {
// Some arguments may need to be boxed
var mparams = method.GetParameters ();
if (mparams.Length != values.Length)
throw new EvaluatorException ("Invalid number of arguments when calling: " + method.Name);
for (int n = 0; n < mparams.Length; n++) {
var tm = mparams[n].ParameterType;
if (tm.IsValueType || tm.IsPrimitive)
continue;
var type = Adapter.GetValueType (this, values[n]);
var argTypeMirror = type as TypeMirror;
var argType = type as Type;
if (IsValueTypeOrPrimitive (argTypeMirror) || IsValueTypeOrPrimitive (argType)) {
// A value type being assigned to a parameter which is not a value type. The value has to be boxed.
try {
values[n] = Thread.Domain.CreateBoxedValue (values [n]);
} catch (NotSupportedException) {
// This runtime doesn't support creating boxed values
throw new EvaluatorException ("This runtime does not support creating boxed values.");
}
}
}
}
if (!method.IsStatic && method.DeclaringType.IsClass && !IsValueTypeOrPrimitive (method.DeclaringType)) {
object type = Adapter.GetValueType (this, target);
var targetTypeMirror = type as TypeMirror;
var targetType = type as Type;
if ((target is StructMirror && ((StructMirror) target).Type != method.DeclaringType) ||
(IsValueTypeOrPrimitive (targetTypeMirror) || IsValueTypeOrPrimitive (targetType))) {
// A value type being assigned to a parameter which is not a value type. The value has to be boxed.
try {
target = Thread.Domain.CreateBoxedValue ((Value) target);
} catch (NotSupportedException) {
// This runtime doesn't support creating boxed values
throw new EvaluatorException ("This runtime does not support creating boxed values.");
}
}
}
try {
return method.Evaluate (target is TypeMirror ? null : (Value) target, values);
} catch (NotSupportedException) {
AssertTargetInvokeAllowed ();
var mc = new MethodCall (this, method, target, values);
Adapter.AsyncExecute (mc, Options.EvaluationTimeout);
return mc.ReturnValue;
}
}