Instantiating diff class from the same interface via config

Mar 13, 2009 at 8:54 PM
 have one interface with 2 classes implementing it, I need to load each class but unity has:

my config looks like:

      <type name="ClassA" type="IGeneric" mapTo="ClassA">
     
</type>
     
<type name="ClassB" type="IGeneric" mapTo="ClassB">
     
</type>

any ideas?

thanks


http://stackoverflow.com/questions/644501/unity-framework-how-to-instantiate-two-classes-from-the-same-interface
Mar 16, 2009 at 2:45 AM
If you want to resolve ClassA, use 
    container.Resolve<IGeneric>("ClassA"); //where "ClassA" is the value of the name attribute.
resolve ClassB,
    container.Resolve<IGeneric>("ClassB");

if you want to resolve both, you can use ResolveAll as provided in the answer posted in the link you provided.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com