I have a typical repository interface, IRepository<T>
, and lots of concrete repositories. Most of the concrete repositories look like this:
class ConcreteRepository<T> : IRepository<T> { .. }
These are easy to register with StructureMap:
For(typeof(IRepository<>)).Use(typeof(ConcreteRepository<>));
However, a select few of my concrete repositories look like this:
class AbnormalRepository<T1, T2> : IRepository<T1>, IAbnormal<T2> { .. }
I still want to use these abnormal repositories as IRepository<T>
s, so for these I'm currently using special rules:
// this sucks!
For(typeof(IRepository<Foo1>)).Use(typeof(AbnormalRepository<Foo1, Bar1>));
For(typeof(IRepository<Foo2>)).Use(typeof(AbnormalRepository<Foo2, Bar2>));
It would be nice if I could just specify a function that StructureMap could use to construct my repositories, since I know that all of my abnormal repositories implement IAbnormal<T>
. Any ideas?