【发布时间】:2012-06-23 02:07:06
【问题描述】:
对于使用远程 WCF 服务的工具包,我在 UnityContainer 中配置了 ChannelFactory<IMyService>。
现在我想通过代码(使用 Unity)配置此通道的端点行为以应用此行为:
<behaviors>
<endpointBehaviors>
<behavior name="BigGraph">
<dataContractSerializer maxItemsInObjectGraph="1000000" />
</behavior>
</endpointBehaviors>
</behaviors>
我在 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();
但现在我被困在 Unity 配置中尝试执行此操作。我应该调查拦截吗?
【问题讨论】:
-
现在我只是构建工厂,应用行为并将其作为实例添加到容器中。
标签: c# .net wcf unity-container