/// <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);
}