Pour une boîte à outils qui utilise un service WCF distant, j'ai configuré un ChannelFactory<IMyService>
dans UnityContainer.Configurer MaxItemsInObjectGraph d'un client WCF lors de l'utilisation de Unity
Maintenant, je veux configurer le comportement de point final de ce canal par le code (en utilisant l'unité) pour appliquer ce comportement:
<behaviors>
<endpointBehaviors>
<behavior name="BigGraph">
<dataContractSerializer maxItemsInObjectGraph="1000000" />
</behavior>
</endpointBehaviors>
</behaviors>
J'ai trouvé cet exemple sur 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();
mais maintenant je suis coincé en essayant de le faire dans une configuration Unity. Devrais-je me pencher sur l'interception?
Pour l'instant je viens de construire l'usine, d'appliquer le comportement et de l'ajouter comme une instance au conteneur. – veertien