本文整理匯總了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;
}
示例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;
}
示例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;
}