title: WCF Reading Endpoint Behaviors from a web.config file
body: <p>I've have a WCF service which has multiple clients that it connects to.</p>
  
  <p>What I want to do is to create the clients dynamically the WCF services consumes.</p>
  
  <p>Creating the clients by inheriting from the <code>ServiceFactory&lt;TChannel&gt;</code> class is done and very simple. What I'm struggling with is how to read Endpoint behaviours from the <code>web.config</code> file and add them to the clients?</p>
  
  <p>Code file</p>
  
  <pre><code>BasicHttpBinding binding = new BasicHttpBinding(bindingConfigName);
  EndpointAddress endpoint = new EndpointAddress(endpointUrl);
  ChannelFactory&lt;IShoppingSoap&gt; clientEndpoint = new ChannelFactory&lt;IShoppingSoap&gt;(binding, endpoint);
  
  base.Endpoint.Behaviors.Add(*Get the behavior from the config file*);
  return base.CreateChannel();
  </code></pre>
  
  <p><code>Web.config</code> file : </p>
  
  <pre><code>&lt;behaviors&gt;  
      &lt;endpointBehaviors&gt;  
         &lt;behavior name="EndpointBehaviour_GmCustom"&gt;
           &lt;dataContractSerializer maxItemsInObjectGraph="2147483646" /&gt;  
         &lt;behavior&gt;  
      &lt;/endpointBehaviors&gt;  
  &lt;/behaviors&gt;
  </code></pre>