Introducing the Osherove.Interception framework
Following the
Nunit Extensibility framework, I did some thinking and made a More generic framework for interception ability. That means that you can create your own interception attributes not only for unit testing but for real world applications as well.
the new solution consists of more real world examples (well, one, but a cool one).
The coolest example so far is an idea triggered by
Peli - it's a Caching attribute.
In this case I created an object that has properties and methods that have an [AutoCache] attribute on them.
this makes them automatically return values from a simple cache object.
Actually - the attribute takes care of everything so the properties and methods actually return NULL.
Yep - it magically just works.
Give it a shot. I like this idea and I think it might have a future.
what do you think?
Download:
Example:
public class MyDataObject:CachedPropertyBag
{
[AutoCached("CustomerList")]
public string[] GetCustomerList()
{
//the beauty here is that any callers to this method will actually
//get a string array with 3 items in it.
//can you say "automagically", boys and girls?
return null;
}
}