Tag: 检查员

使用IParameterInspector.BeforeCall(字符串operationName,object 输入)中止调用

我有一个自定义行为,我实现“IParameterInspector”,以便能够使用BeforeCall和AfterCall。 我正在使用这些方法在我的WCF服务上执行调用之前进行一些validation。 这是我的属性: [AttributeUsage(AttributeTargets.Class)] public class SendReceiveBehaviorAttribute : Attribute, IServiceBehavior { public SendReceiveBehaviorAttribute() { } public void ApplyDispatchBehavior(ServiceDescription desc, ServiceHostBase host) { foreach (ChannelDispatcher cDispatcher in host.ChannelDispatchers) { foreach (EndpointDispatcher eDispatcher in cDispatcher.Endpoints) { foreach (DispatchOperation op in eDispatcher.DispatchRuntime.Operations) { op.ParameterInspectors.Add(MyInspector); } } } } public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection endpoints, BindingParameterCollection bindingParameters) […]