// Token: 0x06000B3D RID: 2877 RVA: 0x00033854 File Offset: 0x00031A54
        internal static DirectoryServiceProxyPool <TClient> CreateDirectoryServiceProxyPool(string endpointName, ServiceEndpoint serviceEndpoint, Trace tracer, int maxNumberOfClientProxies, Binding defaultBinding, GetWrappedExceptionDelegate getTransientWrappedExceptionDelegate, GetWrappedExceptionDelegate getPermanentWrappedExceptionDelegate, ExEventLog.EventTuple errorEvent, bool useDisposeTracker)
        {
            ArgumentValidator.ThrowIfNull("serviceEndpoint", serviceEndpoint);
            ChannelFactory <TClient> factory = DirectoryServiceProxyPool <TClient> .CreateChannelFactory(endpointName, serviceEndpoint, defaultBinding, tracer);

            return(new DirectoryServiceProxyPool <TClient>(endpointName, serviceEndpoint.Uri.Host, tracer, maxNumberOfClientProxies, factory, getTransientWrappedExceptionDelegate, getPermanentWrappedExceptionDelegate, errorEvent, useDisposeTracker));
        }
        private void InitializeServiceProxyPool()
        {
            ExTraceGlobals.TopologyProviderTracer.TraceDebug((long)this.GetHashCode(), "ServiceTopologyprovider - Initializing Service proxy pool");
            NetTcpBinding   defaultBinding  = TopologyServiceClient.CreateAndConfigureTopologyServiceBinding(this.machineName);
            EndpointAddress endpointAddress = TopologyServiceClient.CreateAndConfigureTopologyServiceEndpoint(this.machineName);

            this.serviceProxyPool = DirectoryServiceProxyPool <ITopologyClient> .CreateDirectoryServiceProxyPool("TopologyClientTcpEndpoint", endpointAddress, ExTraceGlobals.TopologyProviderTracer, 3, defaultBinding, new GetWrappedExceptionDelegate(ServiceTopologyProvider.GetTransientWrappedException), new GetWrappedExceptionDelegate(ServiceTopologyProvider.GetPermanentWrappedException), DirectoryEventLogConstants.Tuple_DSC_EVENT_CANNOT_CONTACT_AD_TOPOLOGY_SERVICE, true);
        }
        // Token: 0x06000B3E RID: 2878 RVA: 0x00033894 File Offset: 0x00031A94
        internal static DirectoryServiceProxyPool <TClient> CreateDirectoryServiceProxyPool(string endpointName, ServiceEndpoint serviceEndpoint, Trace tracer, int maxNumberOfClientProxies, List <WSHttpBinding> httpBindings, GetWrappedExceptionDelegate getTransientWrappedExceptionDelegate, GetWrappedExceptionDelegate getPermanentWrappedExceptionDelegate, ExEventLog.EventTuple errorEvent, bool useDisposeTracker)
        {
            ArgumentValidator.ThrowIfNull("serviceEndpoint", serviceEndpoint);
            List <ChannelFactory <TClient> > list = new List <ChannelFactory <TClient> >();

            foreach (Binding defaultBinding in httpBindings)
            {
                list.Add(DirectoryServiceProxyPool <TClient> .CreateChannelFactory(endpointName, serviceEndpoint, defaultBinding, tracer));
            }
            return(new DirectoryServiceProxyPool <TClient>(endpointName, serviceEndpoint.Uri.Host, tracer, maxNumberOfClientProxies, list, getTransientWrappedExceptionDelegate, getPermanentWrappedExceptionDelegate, errorEvent, useDisposeTracker));
        }
        // Token: 0x06000B44 RID: 2884 RVA: 0x00033A08 File Offset: 0x00031C08
        private static ChannelFactory <TClient> CreateChannelFactory(string endpointName, EndpointAddress endpointAddress, Binding defaultBinding, Trace tracer)
        {
            ArgumentValidator.ThrowIfNull("endpointName", endpointName);
            ArgumentValidator.ThrowIfNull("endpointAddress", endpointAddress);
            ArgumentValidator.ThrowIfNull("defaultBinding", endpointAddress);
            ArgumentValidator.ThrowIfNull("tracer", tracer);
            ChannelFactory <TClient> channelFactory = null;

            try
            {
                channelFactory = WcfUtils.TryCreateChannelFactoryFromConfig <TClient>(endpointName);
            }
            catch (Exception ex)
            {
                tracer.TraceError <string, string>(0L, "ServiceProxyPool - Error Creating channel factory from config file for {0}. Details {1}", endpointName, ex.ToString());
                Globals.LogEvent(DirectoryEventLogConstants.Tuple_WcfClientConfigError, endpointName, new object[]
                {
                    endpointName,
                    ex.Message
                });
            }
            if (channelFactory != null)
            {
                string host = endpointAddress.Uri.Host;
                Uri    uri  = channelFactory.Endpoint.Address.Uri;
                string uri2 = string.Format("{0}://{1}:{2}{3}", new object[]
                {
                    uri.Scheme,
                    host,
                    uri.Port,
                    uri.PathAndQuery
                });
                channelFactory.Endpoint.Address = new EndpointAddress(uri2);
            }
            else
            {
                tracer.TraceDebug <string>(0L, "ServiceProxyPool - Creating channel factory for {0} using default configuration", endpointName);
                channelFactory = new ChannelFactory <TClient>(defaultBinding, endpointAddress);
            }
            DirectoryServiceProxyPool <TClient> .ConfigWCFServicePointManager();

            return(channelFactory);
        }
        // Token: 0x06000B45 RID: 2885 RVA: 0x00033B28 File Offset: 0x00031D28
        private static ChannelFactory <TClient> CreateChannelFactory(string endpointName, ServiceEndpoint serviceEndpoint, Binding defaultBinding, Trace tracer)
        {
            ArgumentValidator.ThrowIfNull("endpointName", endpointName);
            ArgumentValidator.ThrowIfNull("serviceEndpoint", serviceEndpoint);
            ArgumentValidator.ThrowIfNull("defaultBinding", defaultBinding);
            ArgumentValidator.ThrowIfNull("tracer", tracer);
            ChannelFactory <TClient> channelFactory = null;

            try
            {
                channelFactory = WcfUtils.TryCreateChannelFactoryFromConfig <TClient>(endpointName);
            }
            catch (Exception ex)
            {
                tracer.TraceError <string, string>(0L, "ServiceProxyPool - Error Creating channel factory from config file for {0}. Details {1}", endpointName, ex.ToString());
                Globals.LogEvent(DirectoryEventLogConstants.Tuple_WcfClientConfigError, endpointName, new object[]
                {
                    endpointName,
                    ex.Message
                });
            }
            if (channelFactory == null)
            {
                channelFactory = new ChannelFactory <TClient>(defaultBinding, serviceEndpoint.Uri.ToString());
            }
            WSHttpBinding wshttpBinding = defaultBinding as WSHttpBinding;

            if (wshttpBinding != null && wshttpBinding.Security.Transport.ClientCredentialType == HttpClientCredentialType.Certificate)
            {
                try
                {
                    channelFactory.Credentials.ClientCertificate.Certificate = TlsCertificateInfo.FindFirstCertWithSubjectDistinguishedName(serviceEndpoint.CertificateSubject);
                }
                catch (ArgumentException ex2)
                {
                    throw new GlsPermanentException(DirectoryStrings.PermanentGlsError(ex2.Message));
                }
            }
            DirectoryServiceProxyPool <TClient> .ConfigWCFServicePointManager();

            return(channelFactory);
        }