tags:

views:

519

answers:

0

For a toolkit that uses a remote WCF service, I have configured a ChannelFactory<IMyService> in a UnityContainer.

Now I want to configure this channel's endpoint behavior through code (using Unity) to apply this behavior:

<behaviors>
  <endpointBehaviors>
   <behavior name="BigGraph">
    <dataContractSerializer maxItemsInObjectGraph="1000000" />
   </behavior>
  </endpointBehaviors>
 </behaviors>

I found this example on MSDN (http://msdn.microsoft.com/en-us/library/ms732038.aspx)

ChannelFactory<IDataService> factory = new ChannelFactory<IDataService>(binding, address);
foreach (OperationDescription op in factory.Endpoint.Contract.Operations)
{
    DataContractSerializerOperationBehavior dataContractBehavior =
                op.Behaviors.Find<DataContractSerializerOperationBehavior>()
                as DataContractSerializerOperationBehavior;
    if (dataContractBehavior != null)
    {
        dataContractBehavior.MaxItemsInObjectGraph = 100000;
    }
}
IDataService client = factory.CreateChannel();

but now I am stuck trying to do this in a Unity configuration. Should I look into Interception?