/// <summary>
        /// 初始化Caller
        /// </summary>
        /// <param name="resolver"></param>
        public void InitCaller(IHttpApiResolver resolver)
        {
            //清理资源
            callTimeouts.Clear();
            callers.Clear();

            //获取拥有ServiceContract约束的服务
            var types = container.GetServiceTypes<ServiceContractAttribute>();

            //初始化字典
            foreach (var type in types)
            {
                //状态服务跳过
                if (type == typeof(IStatusService)) continue;

                var contract = CoreHelper.GetMemberAttribute<ServiceContractAttribute>(type);
                if (contract != null)
                {
                    if (contract.Timeout > 0)
                        callTimeouts[type.FullName] = contract.Timeout;
                }

                if (resolver != null)
                {
                    //添加方法
                    foreach (var httpApi in resolver.MethodResolver(type))
                    {
                        //添加一个新的Caller
                        AddNewCaller(type, httpApi);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 初始化Caller
        /// </summary>
        /// <param name="resolver"></param>
        public void InitCaller(IHttpApiResolver resolver)
        {
            //清理资源
            callTimeouts.Clear();
            callers.Clear();

            //获取拥有ServiceContract约束的服务
            var types = container.GetServiceTypes <ServiceContractAttribute>();

            //初始化字典
            foreach (var type in types)
            {
                //状态服务跳过
                if (type == typeof(IStatusService))
                {
                    continue;
                }

                var contract = CoreHelper.GetMemberAttribute <ServiceContractAttribute>(type);
                if (contract != null)
                {
                    if (contract.Timeout > 0)
                    {
                        callTimeouts[type.FullName] = contract.Timeout;
                    }
                }

                if (resolver != null)
                {
                    //添加方法
                    foreach (var httpApi in resolver.MethodResolver(type))
                    {
                        //添加一个新的Caller
                        AddNewCaller(type, httpApi);
                    }
                }
            }
        }