Aside from the features that I mentioned earlier in this blog, LinFu.AOP will add some interesting features to the LinFu Framework, such as:
Even simpler Simple.IOC integration
With LinFu.AOP, you no longer have to even reference Simple.IOC.dll in your application to use the container. For example, instantiating an IDbConnection type from a SimpleContainer instance will be easy as:
IDbConnection myConnection = New
...that's it! Behind the scenes, LinFu.AOP will actually intercept the call made to the following class:
public class New
{
public static T Instance
{
get { throw new NotImplementedException(); }
}
}
Now, believe it or not, the code listing above is the actual implementation of the New
LinFu.DynamicProxy 'Submersion'
One of LinFu.DynamicProxy's weaknesses is that its interceptor instances can only be bound to an unsealed type with all of its public methods marked virtual. With LinFu.AOP, that limitation no longer applies.
LinFu.AOP allows LinFu.DynamicProxy interceptors to intercept methods and properties on type instances without even using the proxy generator itself. This means that when LinFu.AOP intercepts a method call done against a target type, there is no intermediate proxy doing the interception. LinFu.AOP rewrites the IL in your method body and redirects it to your interceptor, all at runtime. You can even reuse the old method implementation as if you were still using DynamicProxy.
One could even say that the inteceptor has 'submerged' itself into the type implementation because the interceptor can still intercept any method on any given type as if it were still attached to the proxy--however, what makes it 'submerged' is the fact that you're actually using the true object instance itself!
To take this concept even further, LinFu.AOP supports two levels of method interception: Class-Based, and Instance-Based.
This means that you can either intercept a particular method across all instances of a given type, OR you can actually customize the method replacement (or interceptor) based on the current instance that you're using. Think about that for a moment...
...and while you're thinking about that, I'm going to go back and polish this thing up. :)
5 comments:
this kinda busts your bubble...
SpringSource's Update to .NET Adds Key Java Features
or does it...
It doesn't bust my bubble at all.
There are numerous AOP and DI frameworks out there aside from LinFu, and I won't lose much sleep if Spring has their own implementation of AOP. They certainly have their way of doing things, and I have my own ways, which I believe are much more simple.
If they come up with something better than my own creation, well, then good for them. :)
Good to know.
I haven't really delved into how Spring does theirs, but yours was the first one I came across with (in CodeProject) and I immediately wondered why these features were not included in .Net.
Kudos for all your efforts. You really must love programming to devote so much into these features.
Looking forward to more posts :)
Hey, out of curiosity, what are you using under the hood to manipulate IL?
I used Reflection.Emit in LinFu 1.0, and in LinFu 2.0, I've migrated all the Reflection.Emit code to Mono.Cecil.
Post a Comment