Ejemplo n.º 1
0
        /// <summary>
        /// Create service channel.
        /// </summary>
        /// <param name="node">The node name.</param>
        /// <returns></returns>
        public IServiceInterfaceType GetChannel <IServiceInterfaceType>(ServerNode node)
        {
            if (node == null)
            {
                throw new WarningException("Server node can't for empty!");
            }

            //获取服务节点
            if (resolver != null)
            {
                node = resolver.GetServerNode <IServiceInterfaceType>(node);
            }

            //获取本地服务
            var service = GetLocalService <IServiceInterfaceType>();

            if (service == null)
            {
                IService proxy          = null;
                var      isCacheService = true;
                if (singleton.proxies.ContainsKey(node.Key.ToLower()))
                {
                    proxy = singleton.proxies[node.Key.ToLower()];
                }
                else
                {
                    if (node.Format == TransferType.Json)
                    {
                        proxy = new InvokeProxy(node, container);
                    }
                    else
                    {
                        proxy = new RemoteProxy(node, container);
                    }

                    isCacheService = false;
                }

                service = GetProxyChannel <IServiceInterfaceType>(proxy, isCacheService);
            }

            //返回服务
            return(service);
        }