// 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);
        }