views:

50

answers:

0

I'm using subsonic2's generated classes and wanting to add a layer of abstraction for testing, I created a basic interface, as such...

public interface  IController<TCollection>
    where TCollection : class
{
    TCollection FetchAll();
    TCollection FetchByID(object id);
    TCollection FetchByQuery(Query query);
    bool Delete(object id);
    //void Insert(TEntity entity);
    //void Update(TEntity entity);
}

Which is great, I created an "extended" class folder, dropped a class in there and extended that class ...

public partial class AddressController : IController<AddressCollection> { }

NO problems, yay. Then it hit me -- there's 239 of these classes, and I'm not about to go make those by hand, there has to be a way for the software to do this, and I'm lazy, so I started to look at a factory pattern that would return a IController< TCollection >. How would I go about this? I guess a better question is, how do I get reflection to do my evil bidding by taking a class and asking it to use a certain interface?