Step 4. Create the “Interceptor” folder under the Infra project and the Core project, then create two class files under the Infra project’s Interceptor folder and the Core project’s Interceptor folder.
One file name sets “InterceptorHandler.” Another file name sets “InterceptorOfCoreAttribute” or “InterceptorOfInfraAttribute.”
Step 5. Edit the InterceptorHandler file that is under the Core project. Let the InterceptorHandler inherits the ImessageSink interface class, then creating the synchronous process messages function and the asynchronous process message method.
Now, I develop this demo web application project that will focus on the SysncProcessMessage method and won’t focus on the asynchronous process message method because the demo project is the sample project concept. If you want to use the asynchronous process message method and don’t want to use the synchronous process message method, it will be O.K. If you wish only to use the synchronous process message method, it will be O.K. If you consider a complex web project or the huge web project, you must carefully consider the intercept mechanism in your project. Maybe it brings to the performance problems that aren’t about the hardware, the IIS server, etc. It is about software architecture’s design pattern problems.
Note: If you want to see the complete source code about the InterceptorHandler class file, please, click my GitHub repository.
Step 6. Edit the InterceptorOfCoreAttribute file that is under the Core project’s Interceptor folder. The InterceptorOfCoreAttribute class file inherits the ContextAttribute class file and the IContributeObjectSink interface file. Remember, the layer string variable must write this layer name. After the web application is running, the log information will show in your log file or on Visual Studio’s Output view.
public class InterceptorOfCoreAttribute : ContextAttribute, IContributeObjectSink
{
private readonly string layer = "Enterprise_MVC_WebApplication.Core";
public InterceptorOfCoreAttribute() : base("InterceptorOfCoreAttribute") { }
public IMessageSink GetObjectSink(MarshalByRefObject obj, IMessageSink nextSink)
{
return new InterceptorHandler(this.layer, nextSink);
}
} The single-responsibility principle (SRP) is a computer-programming principle that states that every module, class or…
Command query responsibility segregation (CQRS) generalizes CQS to message-driven and event-driven architectures: it applies the CQS…
Domain-driven design (DDD) is a software design approach focusing on modelling software to match a…
A microservice architecture – a variant of the service-oriented architecture (SOA) structural style – arranges…
The Repository pattern and Unit of Work pattern are used together in most time. Unit…
Visitor – It allows the program changes the algorithm and the operations that base on the visitor…