Structuremap and generic types

Posted by James D on Stack Overflow See other posts from Stack Overflow or by James D
Published on 2010-04-15T11:53:59Z Indexed on 2010/04/15 12:43 UTC
Read the original article Hit count: 515

Filed under:
|
|

Hi

I have a situation which seems a bit different from others I've seen. For clarrification, this isn't the normal question eg; something like IAClass maps to AClass etc - that involves using basically a single concrete classes per interface.

This involves having a single generic class, but I want to be able to load ALL possible usages of it.

Eg - the main class is of

public class MyClass<TDomainObject> : IMyClass<TDomainObject> 
     where TDomainObject : DomainObject

So example usages would be

IMyClass<Person> p = new MyClass<Person>;
IMyClass<Employer> p = new MyClass<Employer>;

I.e. for all DomainObjects I would like to be able to load a MyClass<> for. So you can see I don't use a specific class for each declaration, they all use the same one.

How would I get this loaded into StructureMap?

© Stack Overflow or respective owner

Related posts about structuremap

Related posts about c#