I want to share a container with different layers in my application. I started creating a static class that initializes the container and registers types in the container.
public class GeneralDIModule : NinjectModule { public override void Load() { Bind<IDataBroker>().To<DataBroker>().InSingletonScope(); } } public abstract class IoC { private static IKernel _container; public static void Initialize() { _container = new StandardKernel(new GeneralDIModule(), new ViewModelDIModule()); } public static T Get<T>() { return _container.Get<T>(); } }
I noticed that there is a Resolve method. What is the difference between Resolve and Get?
In my unit tests, I do not always want every registered type in my container. Is there a way to initialize an empty container and then register the types I need. I will also mock unit test types, so I must also register them.
There is an Inject method, but it says the instance life cycle is not controlled?
Can someone please configure me correctly?
How can I register, unregister objects and reset the container.
ninject ninject-2
joblot
source share