I have a server&client solution that are using WCF. The client will ask a service about the URL to an active server at runtime and to be able to set this I use ChannelFactory. I however still needs to use all other WCF settings from the config file. This is how I do it : 

```
var clientSection = ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection;

            var address = string.Empty;
            for(int i = 0; i < clientSection.Endpoints.Count; i++)
            {
                if(clientSection.Endpoints[i].Name == endpointConfigurationName)
                {
                    var endpointAddress = new EndpointAddress(clientSection.Endpoints[i].Address.ToString());
                    var netHttpBinding = new NetHttpBinding(clientSection.Endpoints[i].BindingConfiguration);
                    var serviceEndpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(T)), netHttpBinding, endpointAddress);

                    var channelFactory = new ChannelFactory<T>(serviceEndpoint);

                    break;
                }
            }

```

The problem is that I got 2 BehaviorExtensions that are used by some of the endpoints like this.

```
<services>
<endpoint binding="netHttpBinding" behaviorConfiguration="protoEndpointBehavior" address="BinaryHttpProto" bindingNamespace="http://MyApp.ServiceContracts/2007/11" contract="MyApp.ServiceContracts.IMyAppClientService" />
</services>

<behaviors>
<endpointBehaviors>
        <behavior name="protoEndpointBehavior">
          <protobuf />
        </behavior>
      </endpointBehaviors>
    </behaviors>

<extensions>
      <behaviorExtensions>
        <add name="protobuf" type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net, Version=2.0.0.668, Culture=neutral, PublicKeyToken=257b51d87d2e4d67" />
      </behaviorExtensions>
    </extensions>

```

The question is how I read this from the clientSection.Endpoints? and sets it on the channelFactory? I know that I could create then manually like this : 

```
serviceEndpoint.EndpointBehaviors.Add(new ProtoEndpointBehavior());
            serviceEndpoint.EndpointBehaviors.Add(new CustomMessageInspectorBehavior());

```

But then this will be a hard coded static and it will apply to all endpoints, I need to be able to change it from the config.