当前位置: 首页>>代码示例>>C#>>正文


C# MethodMirror.GetParameters方法代码示例

本文整理汇总了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;
		}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:30,代码来源:SoftEvaluationContext.cs

示例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;
		}
开发者ID:rajeshpillai,项目名称:monodevelop,代码行数:23,代码来源:SoftDebuggerSession.cs

示例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;
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:debugger-libs,代码行数:57,代码来源:SoftEvaluationContext.cs

示例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 ();
		}
开发者ID:rajeshpillai,项目名称:monodevelop,代码行数:9,代码来源:SoftDebuggerSession.cs


注:本文中的Mono.Debugger.Soft.MethodMirror.GetParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。