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)
{
vardataContractBehavior = 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?
We are using a build policy extension in unity to add behaviors on the service host. On the client we have a ServiceFactory.
Then we configure unity with an
InjectionFactoryBy doing it this way you can also resolve your behavior through unity if you have some dependencies.