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


C# Argument.Resolve方法代码示例

本文整理汇总了C#中Mono.CSharp.Argument.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# Argument.Resolve方法的具体用法?C# Argument.Resolve怎么用?C# Argument.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.CSharp.Argument的用法示例。


在下文中一共展示了Argument.Resolve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AsTryResolveDynamicArgs

		// Resolve any dynamic params to the type of the target parameters list (for PlayScript only).
		public bool AsTryResolveDynamicArgs (ResolveContext ec, System.Collections.IEnumerable candidates)
		{
			MethodSpec ms = null;
			foreach (MethodSpec possibleMs in candidates) {
				if (possibleMs.Parameters.FixedParameters.Length <= args.Count && 
					possibleMs.Parameters.Count >= args.Count) {
					if (ms != null) {
						ms = null;	// Can't be more than one - or we give up and do a dynamic call..
						break;
					}
					ms = possibleMs;
				}
			}
			if (ms != null) {
				var parameters = ms.Parameters;
				for (var i = 0; i < args.Count; i++) {
					var arg = args [i];
					var paramType = parameters.Types [i];
					if (arg.Expr.Type == ec.BuiltinTypes.Dynamic) {
						var parCastType = paramType.BuiltinType == BuiltinTypeSpec.Type.Dynamic ? ec.BuiltinTypes.Object : paramType;
						var new_arg = new Argument (new Cast (
							new TypeExpression (parCastType, arg.Expr.Location), 
							arg.Expr, arg.Expr.Location), arg.ArgType);
						new_arg.Resolve (ec);
						args [i] = new_arg;
					}
				}
				return true;
			}
			return false;
		}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:32,代码来源:argument.cs

示例2: AsTryResolveDynamicArgs

		// Resolve any dynamic params to the type of the target parameters list (for PlayScript only).
		public bool AsTryResolveDynamicArgs (ResolveContext ec, System.Collections.IEnumerable candidates)
		{
			AParametersCollection parameters = null;

			foreach (MemberSpec memberSpec in candidates) {

				AParametersCollection possibleParams = null;
				int fixedArgsLen = 0;

				if (memberSpec is MethodSpec) {
					MethodSpec methodSpec = memberSpec as MethodSpec;
					possibleParams = methodSpec.Parameters;
					fixedArgsLen = possibleParams.FixedParameters.Length;
					if (methodSpec.IsExtensionMethod)
						fixedArgsLen--;
				} else if (memberSpec is IndexerSpec) {
					IndexerSpec indexerSpec = memberSpec as IndexerSpec;
					possibleParams = indexerSpec.Parameters;
					fixedArgsLen = possibleParams.FixedParameters.Length;
				}

				if (fixedArgsLen == args.Count) {
					if (parameters != null) {
						parameters = null;	// Can't be more than one - or we give up and do a dynamic call..
						break;
					}
					parameters = possibleParams;
				}
			}

			if (parameters != null) {
				for (var i = 0; i < args.Count; i++) {
					var arg = args [i];
					var paramType = parameters.Types [i];
					if (arg.Expr.Type == ec.BuiltinTypes.Dynamic) {
						var parCastType = paramType.BuiltinType == BuiltinTypeSpec.Type.Dynamic ? ec.BuiltinTypes.Object : paramType;
						var new_arg = new Argument (new Cast (
							new TypeExpression (parCastType, arg.Expr.Location), 
							arg.Expr, arg.Expr.Location), arg.ArgType);
						new_arg.Resolve (ec);
						args [i] = new_arg;
					}
				}
				return true;
			}

			return false;
		}
开发者ID:johnv315,项目名称:playscript-mono,代码行数:49,代码来源:argument.cs

示例3: AsTryResolveDynamicArgs

		public bool AsTryResolveDynamicArgs (ResolveContext ec, MemberSpec memberSpec)
		{
			AParametersCollection parameters = null;
			int fixedArgsLen = 0;

			if (memberSpec is MethodSpec) {
				MethodSpec methodSpec = memberSpec as MethodSpec;
				parameters = methodSpec.Parameters;
				fixedArgsLen = parameters.FixedParameters.Length;
				if (methodSpec.IsExtensionMethod)
					fixedArgsLen--;
			} else if (memberSpec is IndexerSpec) {
				IndexerSpec indexerSpec = memberSpec as IndexerSpec;
				parameters = indexerSpec.Parameters;
				fixedArgsLen = parameters.FixedParameters.Length;
			}

			if (parameters == null) {
				return false;
			}

			if (fixedArgsLen < args.Count) {
				// too many arguments
				return false;
			}

			for (var i = 0; i < args.Count; i++) {
				var arg = args [i];
				var paramType = parameters.Types [i];
				if (arg.Expr.Type == ec.BuiltinTypes.Dynamic) {
					var parCastType = paramType.BuiltinType == BuiltinTypeSpec.Type.Dynamic ? ec.BuiltinTypes.Object : paramType;
					var new_arg = new Argument (new Cast (
						new TypeExpression (parCastType, arg.Expr.Location), 
						arg.Expr, arg.Expr.Location), arg.ArgType);
					new_arg.Resolve (ec);
					args [i] = new_arg;
				}
			}
			return true;
		}
开发者ID:rlfqudxo,项目名称:playscript-mono,代码行数:40,代码来源:argument.cs


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