How to instantiate objects of classes that have dependencies injected?
- by chester89
Let's say I have some class with dependency injected:
public class SomeBusinessCaller {
ILogger logger;
public SomeBusinessCaller(ILogger logger) {
this.logger = logger;
}
}
My question is, how do I instantiate an object of that class? Let's say I have an implementation for this, called AppLogger. After I say
ObjectFactory.For<ILogger>().Use<AppLogger>();
how do I call constructor of SomeBusinessCaller? Am I calling
SomeBusinessCaller caller = ObjectFactory.GetInstance<SomeBusinessCaller>();
or there is a different strategy for that?