AOP can be used with OOP. An aspect is an attribute applied to classes, methods, parameters, and properties that, at compile-time, weaves code into the class, method, parameter, or property to which it is applied. This approach allows the cross-cutting concerns of a program to be moved from the business source code to a class library. The concerns are added where needed as attributes. The compiler then weaves the required code in at runtime. This keeps your business code small and readable. In this chapter, we will be using PostSharp. You can download it from https://www.postsharp.net/download.
So, how does AOP work with PostSharp?
You add the PostSharp package to your project. Then, you annotate your code with attributes. The C# compiler builds your code into binary, and then PostSharp analyzes the binary and injects the implementation of the aspects. Although the binaries are modified with injected code at compile-time, your project's...