Chapter 9. Aspect composition: example and execution
This chapter covers
- The ordering of aspects being applied to the same code
- Using aspect roles in PostSharp to specify order/dependency
- Composing the order of interception aspects with DynamicProxy
- Real-world example of composing caching and authorization aspects
As you continue to use AOP, you’ll want to apply multiple aspects to the same pieces of code, and this chapter covers how to compose aspects together in a predictable way. If you’re new to AOP, it’s best to start small until you get the hang of it. Introduce a simple aspect (like logging) to your project and see how it goes. For me, it went well, so I wanted to start creating more aspects to handle more cross-cutting concerns. At some point, though, I’ll run into overlap in the code that aspects get applied to. In chapter 2, we wrote aspects for multiple cross-cutting concerns, all on the same piece of code, repeated here in this listing.