Пример #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;
        }
Пример #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;
        }
Пример #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;
        }
Пример #4
0
        protected CandidateMethod ResolveExtension(IEnumerable <MethodInfo> candidates)
        {
            MethodResolver resolver = new MethodResolver(GetExtensionArgumentTypes());

            return(resolver.ResolveMethod(candidates));
        }
Пример #5
0
 protected Type[] GetExtensionArgumentTypes()
 {
     return(MethodResolver.GetArgumentTypes(GetExtensionArgs()));
 }
Пример #6
0
 protected Type[] GetArgumentTypes()
 {
     return(MethodResolver.GetArgumentTypes(_arguments));
 }