Foreword |
|
xiii | |
Preface |
|
xv | |
Acknowledgments |
|
xvii | |
About this book |
|
xix | |
Part 1 Getting Started With AOP |
|
1 | (52) |
|
|
3 | (18) |
|
|
4 | (10) |
|
|
4 | (4) |
|
|
8 | (5) |
|
|
13 | (1) |
|
|
14 | (5) |
|
|
19 | (2) |
|
|
21 | (32) |
|
|
22 | (2) |
|
|
23 | (1) |
|
Necessary nonfunctional requirements |
|
|
24 | (1) |
|
|
24 | (19) |
|
|
25 | (3) |
|
Testing the business logic |
|
|
28 | (1) |
|
|
29 | (2) |
|
Introducing defensive programming |
|
|
31 | (1) |
|
Working with transactions and retries |
|
|
32 | (3) |
|
|
35 | (3) |
|
|
38 | (5) |
|
|
43 | (2) |
|
|
43 | (1) |
|
Small versus large projects |
|
|
43 | (1) |
|
|
44 | (1) |
|
|
45 | (1) |
|
|
45 | (7) |
|
Start simple and isolate the logging |
|
|
45 | (2) |
|
Refactor defensive programming |
|
|
47 | (2) |
|
Creating an aspect for transactions and retries |
|
|
49 | (1) |
|
Put exception handling into its own class |
|
|
50 | (2) |
|
|
52 | (1) |
Part 2 The Fundamentals of AOP |
|
53 | (116) |
|
3 Call this instead: intercepting methods |
|
|
55 | (24) |
|
|
56 | (7) |
|
PostSharp method interception |
|
|
57 | (3) |
|
Castle DynamicProxy method interception |
|
|
60 | (3) |
|
3.2 Real-world example: data transactions |
|
|
63 | (7) |
|
Ensuring data integrity with begin and commit |
|
|
63 | (4) |
|
When transactions go bad: rollback |
|
|
67 | (1) |
|
When all else fails, retry |
|
|
67 | (3) |
|
3.3 Real-world example: threading |
|
|
70 | (7) |
|
The basics of .NET threading |
|
|
70 | (1) |
|
UI threads and worker threads |
|
|
71 | (3) |
|
Declarative threading with AOP |
|
|
74 | (3) |
|
|
77 | (2) |
|
4 Before and after: boundary aspects |
|
|
79 | (36) |
|
|
80 | (12) |
|
PostSharp method bounding |
|
|
80 | (3) |
|
Method boundaries versus method interception |
|
|
83 | (5) |
|
ASP.NET HttpModule bounding |
|
|
88 | (4) |
|
4.2 Real-world example: detecting mobile users |
|
|
92 | (8) |
|
Offer a link to an application |
|
|
93 | (6) |
|
|
99 | (1) |
|
4.3 Real-world example: caching |
|
|
100 | (14) |
|
|
102 | (1) |
|
An application that could benefit from caching |
|
|
103 | (5) |
|
|
108 | (2) |
|
Retrieving from the cache |
|
|
110 | (3) |
|
|
113 | (1) |
|
|
114 | (1) |
|
5 Get this instead: intercepting locations |
|
|
115 | (26) |
|
5.1 Location interception |
|
|
116 | (3) |
|
Fields and properties in .NET |
|
|
116 | (2) |
|
PostSharp location interception |
|
|
118 | (1) |
|
5.2 Real-world example: lazy loading |
|
|
119 | (9) |
|
Lazy loading approaches in .NET |
|
|
120 | (1) |
|
Implementing lazy loading with AOP |
|
|
121 | (3) |
|
What about lazy-loading fields? |
|
|
124 | (4) |
|
5.3 Real-world example: INotifyPropertyChanged |
|
|
128 | (10) |
|
Using INotifyPropertyChanged in a desktop application |
|
|
128 | (4) |
|
Problems and constraints with INotifyPropertyChanged |
|
|
132 | (2) |
|
Reducing boilerplate with AOP |
|
|
134 | (4) |
|
|
138 | (3) |
|
|
141 | (28) |
|
6.1 Writing tests with NUnit |
|
|
142 | (5) |
|
Writing and running NUnit tests |
|
|
142 | (3) |
|
Testing strategies for aspects |
|
|
145 | (2) |
|
6.2 Castle DynamicProxy testing |
|
|
147 | (9) |
|
|
147 | (2) |
|
|
149 | (7) |
|
|
156 | (12) |
|
Unit testing a PostSharp aspect |
|
|
157 | (1) |
|
|
158 | (4) |
|
Problems with PostSharp and testing |
|
|
162 | (6) |
|
|
168 | (1) |
Part 3 Advanced AOP Concepts |
|
169 | (74) |
|
7 AOP implementation types |
|
|
171 | (20) |
|
|
172 | (1) |
|
|
172 | (11) |
|
|
173 | (3) |
|
|
176 | (7) |
|
|
183 | (5) |
|
|
184 | (1) |
|
|
184 | (4) |
|
7.4 Runtime versus compile-time weaving |
|
|
188 | (2) |
|
|
189 | (1) |
|
Pros of compile-time weaving |
|
|
189 | (1) |
|
|
190 | (1) |
|
8 Using AOP as an architectural tool |
|
|
191 | (22) |
|
8.1 Compile-time initialization and validation |
|
|
192 | (7) |
|
Initializing at compile time |
|
|
193 | (2) |
|
Validating the correct use of an aspect |
|
|
195 | (2) |
|
Real-world example: Threading revisited |
|
|
197 | (2) |
|
8.2 Architectural constraints |
|
|
199 | (6) |
|
|
200 | (3) |
|
Real-world example: NHibernate and virtual |
|
|
203 | (2) |
|
|
205 | (6) |
|
|
206 | (4) |
|
|
210 | (1) |
|
|
211 | (2) |
|
9 Aspect composition: example and execution |
|
|
213 | (30) |
|
9.1 Using multiple aspects |
|
|
214 | (1) |
|
9.2 Aspect roles with PostSharp |
|
|
215 | (4) |
|
|
217 | (1) |
|
|
217 | (2) |
|
9.3 Composing aspects with DynamicProxy |
|
|
219 | (5) |
|
|
219 | (3) |
|
Reducing repetition with custom conventions |
|
|
222 | (2) |
|
9.4 Real-world example: caching and authorization |
|
|
224 | (17) |
|
|
225 | (7) |
|
|
232 | (4) |
|
|
236 | (5) |
|
|
241 | (2) |
Appendix A Ecosystem of .NET AOP tools |
|
243 | (14) |
Appendix B NuGet basics |
|
257 | (8) |
Index |
|
265 | |