Esempio n. 1
0
        private bool ProcessMetaMethodInvocation(MethodInvocationExpression node)
        {
            var targetEntity = node.Target.Entity;
            if (null == targetEntity) return false;
            if (!IsOrContainMetaMethod(targetEntity)) return false;

            var arguments = GetMetaMethodInvocationArguments(node);
            var argumentTypes = MethodResolver.GetArgumentTypes(arguments);
            var resolver = new MethodResolver(argumentTypes);
            var method = resolver.ResolveMethod(EnumerateMetaMethods(targetEntity));
            if (null == method) return false;

            Node replacement = InvokeMetaMethod(method, arguments);
            ReplaceMetaMethodInvocationSite(node, replacement);

            return true;
        }
Esempio n. 2
0
        private bool ProcessMetaMethodInvocation(MethodInvocationExpression node, bool resolvedArgs)
        {
            var targetEntity = node.Target.Entity;
            if (targetEntity == null) return false;
            if (!IsOrContainMetaMethod(targetEntity)) return false;

            var arguments = GetMetaMethodInvocationArguments(node);
            var argumentTypes = MethodResolver.GetArgumentTypes(arguments);
            var resolver = new MethodResolver(argumentTypes);
            var method = resolver.ResolveMethod(EnumerateMetaMethods(targetEntity));
            if (method == null) return false;

            if (ShouldResolveArgsOf(method))
            {
                Visit(node.Arguments);
                InvokeMetaMethod(node, method, GetMetaMethodInvocationArguments(node));
                return true;
            }

            InvokeMetaMethod(node, method, arguments);
            return true;
        }
Esempio n. 3
0
        private bool ProcessMetaMethodInvocation(MethodInvocationExpression node)
        {
            IEntity targetEntity = node.Target.Entity;
            if (null == targetEntity) return false;
            if (!IsOrContainMetaMethod(targetEntity)) return false;

            object[] arguments = GetMetaMethodInvocationArguments(node);
            Type[] argumentTypes = MethodResolver.GetArgumentTypes(arguments);
            MethodResolver resolver = new MethodResolver(argumentTypes);
            CandidateMethod method = resolver.ResolveMethod(EnumerateMetaMethods(targetEntity));
            if (null == method) return false;

            // TODO: cache emitted dispatchers
            MethodDispatcherEmitter emitter = new MethodDispatcherEmitter(method, argumentTypes);
            Node replacement = (Node)emitter.Emit()(null, arguments);
            ReplaceMetaMethodInvocationSite(node, replacement);

            return true;
        }
Esempio n. 4
0
        protected CandidateMethod ResolveExtension(IEnumerable <MethodInfo> candidates)
        {
            MethodResolver resolver = new MethodResolver(GetExtensionArgumentTypes());

            return(resolver.ResolveMethod(candidates));
        }
Esempio n. 5
0
 protected Type[] GetExtensionArgumentTypes()
 {
     return(MethodResolver.GetArgumentTypes(GetExtensionArgs()));
 }
Esempio n. 6
0
 protected Type[] GetArgumentTypes()
 {
     return(MethodResolver.GetArgumentTypes(_arguments));
 }