How to instantiate objects of classes that have dependencies injected?
Posted
by chester89
on Stack Overflow
See other posts from Stack Overflow
or by chester89
Published on 2010-03-24T13:51:35Z
Indexed on
2010/03/24
13:53 UTC
Read the original article
Hit count: 163
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?
© Stack Overflow or respective owner