Search The Blog
About this site

@RoyOsherove

Subscribe!

This site aims to connect all the dots of my online activities - from tools, books blogs and twitter accounts, to upcoming conferences, engagements and user group talks.

from 5whys.com
Twitter: @RoyOsherove
My Book: The Art of Unit Testing
Latest Posts
« Introducing "Project Distributor" - your .Net file and idea sharing ground | Main | [Rediscovered] Advanced debugging tips and stuff you never knew about the "Find" combo box »
Tuesday
Oct122004

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;
      }
}

PrintView Printer Friendly Version

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>