/// <summary>
        /// 拦截方法的调用
        /// </summary>
        /// <param name="target">接口的实例</param>
        /// <param name="method">接口的方法</param>
        /// <param name="parameters">接口的参数集合</param>
        /// <returns></returns>
        public object Intercept(object target, MethodInfo method, object[] parameters)
        {
            var apiActionDescripter = this.GetApiActionDescriptor(method, parameters);
            var apiTask             = ApiTask.CreateInstance(this.ApiConfig, apiActionDescripter);

            if (apiActionDescripter.Return.IsITaskDefinition == true)
            {
                return(apiTask);
            }
            else
            {
                return(apiTask.InvokeAsync());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 拦截方法的调用
        /// </summary>
        /// <param name="target">接口的实例</param>
        /// <param name="method">接口的方法</param>
        /// <param name="parameters">接口的参数集合</param>
        /// <returns></returns>
        public object Intercept(object target, MethodInfo method, object[] parameters)
        {
            if (method.Equals(disposeMethod) == true)
            {
                this.httpApiConfig.Dispose();
                return(null);
            }

            var apiActionDescripter = this.GetApiActionDescriptor(method, parameters);
            var apiTask             = ApiTask.CreateInstance(this.httpApiConfig, apiActionDescripter);

            if (apiActionDescripter.Return.GenericType == typeof(ITask <>))
            {
                return(apiTask);
            }
            else
            {
                return(apiTask.InvokeAsync());
            }
        }