For an upcoming project I am planning to use both dependency injection and aspect oriented programming. I will implement the former by myself, following the DIY dependency injection guide and use LOOM.Net for the AOP part.
The common pattern to create an interweaved type of a logic class and an aspect class is
AspectClass aspect = new AspectClass();
LogicClass logic = Weaver.Create<LogicClass>(aspect);
My intuition would be to perform the interweaving in the glue code, e.g. for the classes ConcreteLogicA which implements ILogicA, which depends on ILogicB implemented by ConcreteLogicB
class MyInjector
{
...
public ILogicA GetLogicA(AspectClass aspectToInterweave)
{
return Weaver.Create<ConcreteLogicA>(aspectToInterweave, GetLogicB(aspectToInterweave));
}
public ILogicB GetLogicB(AspectClass aspectToInterweave)
{
return Weaver.Create<ConcreteLogicB>(aspectToInterweave);
}
...
}
Would this be a viable solution or is it way off the track. The advantage is, that I do not have to mix my logic with my aspects (which is sort of the clue of AOP, admittedly) but this way I am adding a bit more logic to the glue code.