In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.