/// <summary>
        /// 获取FastApiService实例
        /// </summary>
        /// <param name="actionContext">Api行为上下文</param>
        /// <returns></returns>
        private IFastApiService GetFastApiService(ActionContext actionContext)
        {
            try
            {
                var serviceType = actionContext.Action.DeclaringService;
                var instance    = this.DependencyResolver.GetService(serviceType);
                return(instance as IFastApiService);
            }
            catch (Exception ex)
            {
                var exception        = new ResolveException(actionContext.Action.DeclaringService, ex);
                var exceptionContext = new ExceptionContext(actionContext, exception);

                Common.SendRemoteException(actionContext.Session.UnWrap(), exceptionContext);
                this.ExecGlobalExceptionFilters(exceptionContext);
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// 获取FastApiService实例
        /// </summary>
        /// <param name="actionContext">Api行为上下文</param>
        /// <returns></returns>
        private IFastApiService GetFastApiService(ActionContext actionContext)
        {
            IFastApiService fastApiService = null;
            Exception       innerException = null;

            try
            {
                fastApiService = (IFastApiService)this.DependencyResolver.GetService(actionContext.Action.DeclaringService);
            }
            catch (Exception ex)
            {
                innerException = ex;
            }

            if (fastApiService == null)
            {
                var exception        = new ResolveException(actionContext.Action.DeclaringService, innerException);
                var exceptionContext = new ExceptionContext(actionContext, exception);

                FastTcpCommon.SetRemoteException(actionContext.Session, exceptionContext);
                this.ExecGlobalExceptionFilters(exceptionContext);
            }
            return(fastApiService);
        }