2 Interfaces on same singleton class, configure in config file

Dec 6, 2012 at 7:22 AM

Hi,

I had a class with implement two Interfaces.

Via code I can ensure to bind each interface on a singleton instance of the class)

...
var container = new UnityContainer(); 
var instance = container.Resolve<DoIt>();
container.RegisterInstance<ISomethingA>(instance);
container.RegisterInstance<ISomethingB>(instance);
var objA = container.Resolve<ISomethingA>();
var objB = container.Resolve<ISomethingB>();
...

public class DoIt : ISomethingA, ISomethingB { 
public void xxx() { }
public void yyy() { }
}
 
public interface ISomethingA { void xxx(); } 
public interface ISomethingB { void yyy(); }
But I want this piece of code in the config.exe file
How can I do this ?
Many thanks
WilliBald
Dec 6, 2012 at 9:49 AM

Hi

know its working!

Mapping two Interfaces on the same class in the config file do the job.

With .Resolve<Interface> there will be one instance.

WilliBald