public OverloadResolutionData <MethodInfo> Resolve(VelocityOperator operatorType, Type left, Type right) { var candidates = GetCandidateUserDefinedOperators(operatorType, left, right); if (!candidates.Any()) { candidates = GetBuiltInOperators(operatorType); } return(_overloadResolver.Resolve(candidates, ImmutableList.Create(left, right))); }
private Expression IndexExpression(DynamicMetaObject target, DynamicMetaObject[] args, IEnumerable <PropertyInfo> candidateProperties) { var typeArgs = args.Select(x => x.LimitType).ToImmutableArray(); var candidateData = candidateProperties.Select(x => new FunctionMemberData <PropertyInfo>(x, x.GetIndexParameters())); var result = _overloadResolver.Resolve(candidateData, typeArgs); if (result == null) { return(null); } var argExpressions = _overloadResolver.CreateParameterExpressions(result, args); var indexer = result.FunctionMember; var targetExpression = VelocityExpressions.ConvertIfNeeded(target.Expression, indexer.DeclaringType); return(Expression.MakeIndex(targetExpression, indexer, argExpressions)); }
public OverloadResolutionData <MethodInfo> ResolveMethod(TypeInfo type, string name, IImmutableList <Type> argTypes) { if (type == null) { throw new ArgumentNullException(nameof(type)); } IEnumerable <MethodInfo> candidateMethods; if (typeof(Delegate).IsAssignableFrom(type)) { candidateMethods = new[] { type.GetMethod("Invoke") } } ; else { candidateMethods = GetCandidateMethods(type, name); } var candidates = candidateMethods .Select(x => new FunctionMemberData <MethodInfo>(x, x.GetParameters())); return(_overloadResolver.Resolve(candidates, argTypes)); }