Create type at runtime that inherits an abstract class and implements an interface
<p>Our architecture uses the Repository pattern extensively.
We have an abstract base class for most of the repositories that implements some common functionality (e.g. get, load, list etc). There is a corresponding interface for this base class, IRepository, which defines the public methods of the abstract class. Most entities have a corresponding interface for the repository, e.g. the Foo entity has an IFooRepository, which in turn implements IRepository.</p>

<p>What I have just described is fairly typical, although I know it is not without problems. But anyway, it is what we have and we have to live with it.</p>

<p>One of my pet-hates with this type of architecture is having to define empty classes that simply inherit the base Repository class and do nothing else, e.g:</p>

<pre><code>public class FooRepository : Repository, IFooRepository
{
}
</code></pre>

<p>One way of getting around this redundant code, is to allow our IOC framework to dynamically create these classes at runtime, so that I don't have to write them myself. If I can work out how to create these classes dynamically, then I already know where to plug them into NInject.</p>

<p>Does anyone know of a some code that can create such a class? Perhaps this can be done with a Proxy framework such as Castle?</p>
