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); }
public static Type GetReturnType(IInvocation invocation) { try { if (invocation != null && invocation.Invoker != null && 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(invocation.MethodName, invocation.ParameterTypes); if (method.ReturnType == typeof(void)) { return(null); } return(method.ReturnType); } } } catch (Exception) { // } return(null); }
public static Type[] GetParameterTypes(IInvocation invocation) { if (Constants.Invoke.Equals(invocation.MethodName) && invocation.Arguments != null && invocation.Arguments.Length > 1 && invocation.Arguments[1] is string[]) { string[] types = (string[])invocation.Arguments[1]; if (types == null) { return(new Type[0]); } Type[] parameterTypes = new Type[types.Length]; for (int i = 0; i < types.Length; i++) { parameterTypes[i] = ReflectUtil.ForName(types[0]); } return(parameterTypes); } return(invocation.ParameterTypes); }