Skip to content
James Craig edited this page May 15, 2014 · 1 revision

The AOP system in CUL is mainly designed as an internal system for things like lazy loading for the ORM. However you can ties into it yourself but it does take some work. The AOP approach used by the system is not by doing any code weaving but instead simply creates a sub class that that inherits from the type specified. For instance:

Utilities.DataTypes.AOP.Manager Test = new Utilities.DataTypes.AOP.Manager(new Compiler());
AOPTestClass Item = (AOPTestClass)Test.Create(typeof(AOPTestClass));

The code above takes the AOPTestClass type and generates a sub class that overrides any/all virtual functions and properties that it finds. It does this by loading any aspects that are found in the system and using those to generate the code for the sub class. In order to create the aspect, you simply implement the IAspect interface found in Utilities.DataTypes.AOP.Interfaces. There are a couple of functions and properties that need to be set. Each one is rather straightforward. If you would like a detailed example, I suggest that you take a look at the lazy loading aspect that the ORM uses. It can be found at Utilities.ORM.Manager.Aspect.

Clone this wiki locally