Exemplo n.º 1
0
        public static Type[] GetReturnTypes(IInvocation invocation)
        {
            try
            {
                if (invocation?.ReturnType != null)
                {
                    return new[] { invocation.ReturnType }
                }
                ;
                if (invocation?.Invoker?.GetUrl() != null && !invocation.MethodName.StartsWith("$"))
                {
                    string service = invocation.Invoker.GetUrl().ServiceName;

                    if (!string.IsNullOrEmpty(service))
                    {
                        Type       cls    = ReflectUtil.ForName(service);
                        MethodInfo method = cls.GetMethod(ReflectUtil.GetCsMethodName(invocation.MethodName), invocation.ParameterTypes);
                        if (method.ReturnType == typeof(void))
                        {
                            return(null);
                        }

                        return(new Type[] { method.ReturnType });
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }

            return(null);
        }