當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。