本文整理汇总了C#中Mono.Debugger.Soft.MethodMirror.GetParameters方法的典型用法代码示例。如果您正苦于以下问题:C# MethodMirror.GetParameters方法的具体用法?C# MethodMirror.GetParameters怎么用?C# MethodMirror.GetParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Debugger.Soft.MethodMirror
的用法示例。
在下文中一共展示了MethodMirror.GetParameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RuntimeInvoke
public Value RuntimeInvoke (MethodMirror method, object target, Value[] values)
{
if (values != null) {
// Some arguments may need to be boxed
ParameterInfoMirror[] 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++) {
TypeMirror tm = mparams [n].ParameterType;
if (tm.IsValueType || tm.IsPrimitive)
continue;
object type = Adapter.GetValueType (this, values [n]);
TypeMirror argTypeMirror = type as TypeMirror;
Type argType = type as Type;
if ((argTypeMirror != null && (argTypeMirror.IsValueType || argTypeMirror.IsPrimitive)) || (argType != null && (argType.IsValueType || argType.IsPrimitive))) {
// 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
break;
}
}
}
}
MethodCall mc = new MethodCall (this, method, target, values);
Adapter.AsyncExecute (mc, Options.EvaluationTimeout);
return mc.ReturnValue;
}
示例2: CheckMethodParams
bool CheckMethodParams (MethodMirror method, string[] paramTypes)
{
if (paramTypes == null) {
// User supplied no params to match against, match anything we find.
return true;
}
int i = 0;
foreach (var param in method.GetParameters ()) {
if (i == paramTypes.Length) {
// This method has too many parameters...
return false;
}
if (param.ParameterType.FullName != paramTypes[i] &&
param.ParameterType.CSharpName != paramTypes[i])
return false;
i++;
}
return i == paramTypes.Length;
}
示例3: 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;
}
}
示例4: GetParamTypes
string[] GetParamTypes (MethodMirror method)
{
List<string> paramTypes = new List<string> ();
foreach (var param in method.GetParameters ())
paramTypes.Add (param.ParameterType.CSharpName);
return paramTypes.ToArray ();
}