-
Notifications
You must be signed in to change notification settings - Fork 0
Runtime Aspects based on Castle DynamicProxy, nice to use in combination with DI
License
chrido/NAdvisor
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
#######################################################################################################################
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());
About
Runtime Aspects based on Castle DynamicProxy, nice to use in combination with DI
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published