NJect – An AOP Wrapper Around Isolator API

Isolator provides an event called MockedMethodCalled that can be used to get notification when a method is called. That means that Isolator is an AOP engine. With this feature you can raise an event and perform logic when the method is executed with ease.

But now it’s even easier. Artem Smirnov, creator of Ivonna, created  NJect, a lightweight wrapper for this API,  with simple API to create your own aspect on top of any method. You can perform your logic before, after or instead of a method.

If you are hardcore and wants something more flexibility, you can Isolator’s Decorator attribute. It allows you to set a more robust mechanism of AOP, around both methods and classes. There’s also a video of how to use it here.

And for those of you asking: Is the new Isolator API going to make it easier to do this? The answer is Yes. Like we said before, in time, we’re going to have the current set of features supported by the new API. So watch this space for updates. And give NJect a try.

  • matt

    So where’s the big huge red letters warning about “USE AT YOUR OWN RISK”??? AOP is great but combined with the power of TypeMock…evil lurks…

  • Eli Lopian

    There are not warning letters, because they are not needed. It is only good.

    I am not sure what your definition of AOP is, but for many other languages there are Dynamic AOP engines. These enable adding and mixing code at runtime. This is what NJect wants to achieve.

    Example of usage:
    Using it a developer can (at runtime) decide that ALL entrances into methods be logged without actually requiring you to modify a single line of code.
    So if an error happens at a customer site, you can be easy to get logs of the code flow.