本文整理汇总了C#中Microsoft.Scripting.Actions.Calls.BindingTarget.MakeExpression方法的典型用法代码示例。如果您正苦于以下问题:C# BindingTarget.MakeExpression方法的具体用法?C# BindingTarget.MakeExpression怎么用?C# BindingTarget.MakeExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Scripting.Actions.Calls.BindingTarget
的用法示例。
在下文中一共展示了BindingTarget.MakeExpression方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallMethod
/// <summary>
/// Performs binding against a set of overloaded methods using the specified arguments. The arguments are
/// consumed as specified by the CallSignature object.
/// </summary>
/// <param name="minLevel">TODO.</param>
/// <param name="maxLevel">TODO.</param>
/// <param name="resolver">Overload resolver.</param>
/// <param name="targets">The methods to be called</param>
/// <param name="restrictions">Additional restrictions which should be applied to the resulting MetaObject.</param>
/// <param name="target">The resulting binding target which can be used for producing error information.</param>
/// <param name="name">The name of the method or null to use the name from targets.</param>
/// <returns>A meta object which results from the call.</returns>
public DynamicMetaObject CallMethod(DefaultOverloadResolver resolver, IList<MethodBase> targets, BindingRestrictions restrictions, string name,
NarrowingLevel minLevel, NarrowingLevel maxLevel, out BindingTarget target) {
ContractUtils.RequiresNotNull(resolver, "resolver");
ContractUtils.RequiresNotNullItems(targets, "targets");
ContractUtils.RequiresNotNull(restrictions, "restrictions");
// attempt to bind to an individual method
target = resolver.ResolveOverload(name ?? GetTargetName(targets), targets, minLevel, maxLevel);
if (target.Success) {
// if we succeed make the target for the rule
return new DynamicMetaObject(
target.MakeExpression(),
restrictions.Merge(
MakeSplatTests(resolver.CallType, resolver.Signature, resolver.Arguments).
Merge(target.RestrictedArguments.GetAllRestrictions())
)
);
}
// make an error rule
return MakeInvalidParametersRule(resolver, restrictions, target);
}
示例2: CallWorker
private DynamicMetaObject CallWorker(ParameterBinder parameterBinder, IList<MethodBase> targets, IList<DynamicMetaObject> args, CallSignature signature, CallTypes callType, BindingRestrictions restrictions, NarrowingLevel minLevel, NarrowingLevel maxLevel, string name, out BindingTarget target) {
ContractUtils.RequiresNotNull(parameterBinder, "parameterBinder");
ContractUtils.RequiresNotNullItems(args, "args");
ContractUtils.RequiresNotNullItems(targets, "targets");
ContractUtils.RequiresNotNull(restrictions, "restrictions");
DynamicMetaObject[] finalArgs;
SymbolId[] argNames;
if (callType == CallTypes.ImplicitInstance) {
GetArgumentNamesAndTypes(signature, ArrayUtils.RemoveFirst(args), out argNames, out finalArgs);
finalArgs = ArrayUtils.Insert(args[0], finalArgs);
} else {
GetArgumentNamesAndTypes(signature, args, out argNames, out finalArgs);
}
// attempt to bind to an individual method
MethodBinder binder = MethodBinder.MakeBinder(
this,
name ?? GetTargetName(targets),
targets,
argNames,
minLevel,
maxLevel);
target = binder.MakeBindingTarget(callType, finalArgs);
if (target.Success) {
// if we succeed make the target for the rule
return new DynamicMetaObject(
target.MakeExpression(parameterBinder),
restrictions.Merge(MakeSplatTests(callType, signature, args).Merge(BindingRestrictions.Combine(target.RestrictedArguments)))
);
}
// make an error rule
return MakeInvalidParametersRule(callType, signature, this, args, restrictions, target);
}