If have two classes Class1
and Class2
both implementing an interface IInterface
.
And now if I need a singleton instance of each of these classes, would this be the right way to implement it?
c.ForSingletonOf<IInterface>().Use<Class1>().Named("Class1");
c.ForSingletonOf<IInterface>().Add<Class2>().Named("Class2");
And then getting the instances like this:
container.GetInstance<IInterface>("Class1");
container.GetInstance<IInterface>("Class2");
Is there anything wrong in this approach or is there a better approach?