コード例 #1
0
        private static void InitializeChannelConfig(IConfiguration config, RpcConfig instance)
        {
            var channelNode = config.GetSection("channel");

            if (channelNode?.GetChildren()?.Any() != true)
            {
                return;
            }

            var providersNode = channelNode.GetSection("providers");
            var providers     = providersNode.GetChildren();

            instance.Client.Channel = new ChannelConfig {
                Providers = new List <ChannelProviderConfig>()
            };
            foreach (var item in providers)
            {
                var name = item["name"];
                var type = item["type"];

                if (string.IsNullOrEmpty(type))
                {
                    throw new RpcConfigException($"type of RpcLite configuration client node '{name}' can't be null or empty");
                }

                var serviceConfigItem = new ChannelProviderConfig
                {
                    Name = name,
                    Type = type,
                };
                instance.Client.Channel.Providers.Add(serviceConfigItem);
            }
        }
コード例 #2
0
        private static void InitializeChannelConfig(IConfiguration config, RpcConfig instance)
        {
            var channelNode = config.GetSection("channel");
            if (channelNode?.GetChildren()?.Any() != true) return;

            var providersNode = channelNode.GetSection("providers");
            var providers = providersNode.GetChildren();
            instance.Client.Channel = new ChannelConfig { Providers = new List<ChannelProviderConfig>() };
            foreach (var item in providers)
            {
                var name = item["name"];
                var type = item["type"];

                if (string.IsNullOrEmpty(type))
                    throw new RpcConfigException($"type of RpcLite configuration client node '{name}' can't be null or empty");

                var serviceConfigItem = new ChannelProviderConfig
                {
                    Name = name,
                    Type = type,
                };
                instance.Client.Channel.Providers.Add(serviceConfigItem);
            }
        }