public EmployeeClientProxyFactory(IClientProxySettings proxySettings)
        {
            _proxySettings  = proxySettings;
            _channelFactory = new Lazy <System.ServiceModel.ChannelFactory <IEmployeeService> >(() =>
            {
                var binding         = _proxySettings.GetNetTcpBinding();
                var endpointAddress = _proxySettings.GetEndpointAddress();

                var factory = new System.ServiceModel.ChannelFactory <IEmployeeService>(binding, endpointAddress);
                factory.Endpoint.TrySetMaxItemsInObjectGraph(_proxySettings);

                return(factory);
            });
        }
Пример #2
0
        public IEmployeeClient GetClient(ClientType?clientType = null)
        {
            bool isProxyEnabled = _proxySettings?.Enabled ?? false;

            if (isProxyEnabled && clientType == ClientType.ManualBindings)
            {
                var binding         = _proxySettings.GetNetTcpBinding();
                var endpointAddress = _proxySettings.GetEndpointAddress();

                var client = new EmployeeClient(binding, endpointAddress);
                client.TrySetMaxItemsInObjectGraph(_proxySettings);

                return(client);
            }

            if (isProxyEnabled && clientType == ClientType.ChannelFactory)
            {
                return(new ManuallyConfiguredEmployeeClient(_channelFactory.Value, _logger));
            }

            // this does not work in netcore mode since this relies on automatic configuration
            return(new EmployeeClient());
        }