本文整理汇总了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;
}