public ChannelManager(ChannelPoolSettings settings, IList <ServiceEndpoint> endpoints)
        {
            this.channelPool  = new PooledChannelPool(settings);
            this.factoryCache = new Dictionary <EndpointAddress, ChannelFactoryReference>();

            this.newChannels = new List <PooledChannel>();

            this.endpoints        = new Dictionary <EndpointAddress, ServiceEndpoint>();
            this.endpointMappings = Hashtable.Synchronized(new Hashtable());

            if (endpoints != null)
            {
                foreach (ServiceEndpoint endpoint in endpoints)
                {
                    if (endpoint != null)
                    {
                        EndpointAddress cacheAddress = null;
                        if (endpoint.Contract.ContractType != null)
                        {
                            cacheAddress = ChannelManagerHelpers.BuildCacheAddress(endpoint.Name, endpoint.Contract.ContractType);
                        }
                        else
                        {
                            cacheAddress = ChannelManagerHelpers.BuildCacheAddress(endpoint.Name, endpoint.Contract.Name);
                        }
                        this.endpoints.Add(cacheAddress, endpoint);
                    }
                }
            }
        }
 internal void InitializeFrom(ChannelPoolSettings settings)
 {
     if (settings == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("settings");
     }
     this.IdleTimeout  = settings.IdleTimeout;
     this.LeaseTimeout = settings.LeaseTimeout;
     this.MaxOutboundChannelsPerEndpoint = settings.MaxOutboundChannelsPerEndpoint;
 }
 internal void ApplyConfiguration(ChannelPoolSettings settings)
 {
     if (settings == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("settings");
     }
     settings.IdleTimeout  = this.IdleTimeout;
     settings.LeaseTimeout = this.LeaseTimeout;
     settings.MaxOutboundChannelsPerEndpoint = this.MaxOutboundChannelsPerEndpoint;
 }
Esempio n. 4
0
        internal void InitializeFrom(ChannelPoolSettings settings)
        {
            if (null == settings)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("settings");
            }

            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.IdleTimeout, settings.IdleTimeout);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.LeaseTimeout, settings.LeaseTimeout);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxOutboundChannelsPerEndpoint, settings.MaxOutboundChannelsPerEndpoint);
        }
Esempio n. 5
0
        void Container3()
        {
            //ChannelManagerService.ChannelManagerService(ChannelPoolSettings)
            //<snippet3>
            ChannelPoolSettings settings = new ChannelPoolSettings();

            settings.IdleTimeout  = TimeSpan.FromMinutes(10);
            settings.LeaseTimeout = TimeSpan.FromMinutes(1);
            settings.MaxOutboundChannelsPerEndpoint = 10;
            ChannelManagerService service = new ChannelManagerService(settings);
            //</snippet3>
        }
Esempio n. 6
0
        public ChannelManagerService(ChannelPoolSettings settings, IList <ServiceEndpoint> endpoints)
        {
            if (settings == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("settings");
            }

            if (endpoints == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpoints");
            }

            this.settings      = settings;
            this.codeEndpoints = endpoints;
        }
Esempio n. 7
0
        void Container4()
        {
            //ChannelManagerService.ChannelManagerService(ChannelPoolSettings, Ilist)
            ContractDescription contractDescription = null;
            //<snippet4>
            ChannelPoolSettings settings = new ChannelPoolSettings();

            settings.IdleTimeout  = TimeSpan.FromMinutes(10);
            settings.LeaseTimeout = TimeSpan.FromMinutes(1);
            settings.MaxOutboundChannelsPerEndpoint = 10;
            IList <ServiceEndpoint> endpoints = new List <ServiceEndpoint>();

            endpoints.Add(new ServiceEndpoint(contractDescription));
            ChannelManagerService service = new ChannelManagerService(settings, endpoints);
            //</snippet4>
        }
 public PooledChannelPool(ChannelPoolSettings settings)
     : base(settings.MaxOutboundChannelsPerEndpoint, settings.IdleTimeout, settings.LeaseTimeout)
 {
 }
Esempio n. 9
0
        public ChannelManagerService(NameValueCollection parameters)
        {
            if (parameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters");
            }

            ChannelPoolSettings channelPoolSettings = new ChannelPoolSettings();

            foreach (string key in parameters.Keys)
            {
                if (string.IsNullOrEmpty(key))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(
                              SR2.GetString(SR2.Error_UnknownConfigurationParameter, key), "parameters");
                }
                else if (key.Equals(ChannelManagerService.IdleTimeoutSetting, StringComparison.OrdinalIgnoreCase))
                {
                    try
                    {
                        channelPoolSettings.IdleTimeout =
                            ConvertToTimeSpan(parameters[ChannelManagerService.IdleTimeoutSetting]);
                    }
                    catch (FormatException ex)
                    {
                        ArgumentException exception = new ArgumentException(
                            SR2.GetString(SR2.Error_InvalidIdleTimeout, parameters[ChannelManagerService.IdleTimeoutSetting]),
                            "parameters",
                            ex);

                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception);
                    }
                }
                else if (key.Equals(ChannelManagerService.LeaseTimeoutSetting, StringComparison.OrdinalIgnoreCase))
                {
                    try
                    {
                        channelPoolSettings.LeaseTimeout =
                            ConvertToTimeSpan(parameters[ChannelManagerService.LeaseTimeoutSetting]);
                    }
                    catch (FormatException ex)
                    {
                        ArgumentException exception = new ArgumentException(
                            SR2.GetString(SR2.Error_InvalidLeaseTimeout, parameters[ChannelManagerService.LeaseTimeoutSetting]),
                            "parameters",
                            ex);

                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception);
                    }
                }
                else if (key.Equals(ChannelManagerService.MaxIdleChannelsPerEndpointSetting, StringComparison.OrdinalIgnoreCase))
                {
                    try
                    {
                        channelPoolSettings.MaxOutboundChannelsPerEndpoint =
                            Convert.ToInt32(parameters[ChannelManagerService.MaxIdleChannelsPerEndpointSetting], System.Globalization.CultureInfo.CurrentCulture);
                    }
                    catch (FormatException ex)
                    {
                        ArgumentException exception = new ArgumentException(
                            SR2.GetString(SR2.Error_InvalidMaxIdleChannelsPerEndpoint, parameters[ChannelManagerService.MaxIdleChannelsPerEndpointSetting]),
                            "parameters",
                            ex);

                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception);
                    }
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(
                              SR2.GetString(SR2.Error_UnknownConfigurationParameter, key), "parameters");
                }
            }

            this.settings      = channelPoolSettings;
            this.codeEndpoints = new List <ServiceEndpoint>();
        }
Esempio n. 10
0
 public ChannelManagerService(ChannelPoolSettings settings)
     : this(settings, new List <ServiceEndpoint>())
 {
 }