【发布时间】:2010-06-20 01:36:26
【问题描述】:
我需要在我的服务中使用自定义 IOperationInvoker。我让它工作得很好,但我并不特别喜欢这样的想法,即为了将其应用于给定的操作,我必须将其设为属性。我似乎找不到任何关于如何配置它的文档(类似于端点上的 MessageInspector)。
我创建了一个实现 IEndpointBehavior 的 CustomBehavior。在 ApplyDispathBehavior 我有以下内容:
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
foreach (var operation in endpointDispatcher.DispatchRuntime.Operations)
{
operation.Invoker = new MockServiceOperationInvoker() {Invoker=operation.Invoker };
}
}
但是,自定义调用程序似乎并没有“坚持”。是否可以在生命周期的后期清除更改?
如果我将行为作为属性,一切都会起作用,但我宁愿不这样做。有谁知道将自定义 OperationBInvoker 应用于给定端点中的所有方法的更好方法?
非常感谢!
【问题讨论】: