In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to achieve WCF behavior extension". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to achieve WCF behavior extension.
WCF provides convenience for developers with its flexible and extensible architecture, of which WCF behavior extension is perhaps the most common in applications. Custom extensions to behavior are not complex, but there are still many details to pay attention to.
On the server side, DispatchRuntime and DispatchOperation are generally extended. The extension points include checking parameters and messages, and operation invocation programs, and their corresponding interfaces are IParameterInspector,IDispatchMessageInspector and IOperationInvoker, respectively. On the client side, ClientRuntime and ClientOperation are extended, and the extension point includes checking parameters and messages, and the corresponding interfaces are IParameterInspector and IClientMessageInspector, respectively. These interface types are defined under the System.ServiceModel.Dispatcher namespace, where the IParameterInspector interface can act on both the server and the client.
The implementation of these interfaces is somewhat similar to the implementation of AOP, where some additional logic can be injected before and after the method call, so these extensions are often referred to as listeners. For example, the IParameterInspector interface defines the following methods:
Void AfterCall (string operationName, object [] outputs, object returnValue, object correlationState); object BeforeCall (string operationName, object [] inputs)
The BeforeCall method is called before calling the target method of the service object, and the AfterCall method is called after the call. For example, we can verify whether the parameter of the calculated method is less than 0 before the method call, and throw an exception if it is less than 0:
Public class CalculatorParameterInspector:IParameterInspector {public void BeforeCall (string operationName, object [] inputs) {int x = inputs [0] as int; int y = inputs [1] as int; if (x
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.