I have one interface: IFoo
Two classes implementing that interface: FooOne
and FooTwo
And two classes ClassOne
and
You need to give them registration names to do this:
// Create an instance of a service you want to use. Alternatively, this
// may have been created by another process and passed to your application
LoggingService myLoggingService = new LoggingService();
// Register the existing object instance with the container
container.RegisterInstance("Logging", myLoggingService);
// Register a mapping for another service your application will use
container.RegisterType("DataService");
// When required, retrieve an instance of these services
IMyService theDataService = container.Resolve("DataService");
IMyService theLoggingService = container.Resolve("Logging");
Taken from Resolving Instances Of Types Using Unity