Can anyone think of a good solution for getting IOC into a console application?
At the moment we are just using a static class with the following method:
public static T Resolve<T>() { return dependencyResolver.Resolve<T>(); }
I would like the experience to be seamless but cannot think of a way of achieving this from a console application.
You will have to make a service locater call (
Resolve<T>()) somewhere. The trick is to get it as out-of-the-way as possible. For console applications this bootstrapping happens in theMain()method. Do it there and minimize those Resolve calls elsewhere and you’ll be great. For most dependencies, use constructor injection.