Aspect Oriented Programming in C# using DispatchProxy

Introduction
Aspect Oriented Programming (AOP) is a very powerful approach to avoid boilerplate code and archive better modularity. The main idea is to add behavior (advice) to the existing code without making any changes in the code itself. AOP provides a way of weaving an aspect into the code. An aspect is supposed to be generic so it can be applied to any object and an object should not have to know anything about advice. AOP allows the developer to separate cross-cutting concerns and makes it easier to follow the Single Responsibility Principle (one of the SOLID principles). Logging, security, transactions, and exception handling are the most common examples of using AOP. If you are not familiar with this programming technique you can read this or this. Don’t be scared if you still do not understand what it’s all about. After looking at several examples, it becomes much easier to understand.
In Java, AOP is implemented in the AspectJ and Spring frameworks. There are PostSharp (not free), NConcern, and some other frameworks (not very popular or easy to use) to do almost the same stuff in.NET.

Link: https://dzone.com/articles/aspect-oriented-programming-in-c-using-dispatchpro?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev