-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
35 lines (25 loc) · 1.64 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#######################################################################################################################
NAdivsor
#######################################################################################################################
NAdvisor is a small library which adds Aspects during runtime.
If you are looking for traditional Aspects have a look at postsharp.org
The differences compared to traditional Aspects are:
- Aspects can be instantiated, therefor can have dependencies in the constructor (fits very well with DI)
- Pointcuts/Join Points can be changed during runtime
- Aspects can have a different lifetime than theire intercepted classes.
Some things which are difficult to do with compile time weaved Aspects but are trivial with NAdvisor:
- unit testing with or without aspects
- unit testing of your logic inside the aspects
- JointPoints can be determined during runtime
- because aspects are normal objects, they can be instantiated, they can have dependencies.
- using Mocked aspects during unit tests
- swap JointPoint definition during runtime (e.g. switching on/off performance measuring aspect)
- no impact on build time
- readable stacktraces
Usage:
//Instantiate a new SecurityAspect
IAspect securityAspect = new SecurityAspect(user);
//Creates a Proxy, chooses the Aspect from the List by the JointPointDefinition
Advisor advisor = new Advisor(JointPointDefinition.AttributeBasedJointPointDefinition, new List<IAspect>() {securityAspect, loggingAspect});
//Gets a Proxy which is intercepted by the Securityaspect and Loggingaspect
ISimpleService myService = advisor.GetAdvicedProxy<ISimpleService>(new SimpleService());