Having an issue finding a straight answer on this, although that might well be a failure on my part to search for the correct terms.
What i want to know, is in caliburn micro using IoC.Get(); returns a reference to that existing object, and also ( I assume ) if there is no instance of that object the IoC will create one
Also, what if i was to create an instance manually via new, and later used ioc.get, would this return the same instance i created manually or a new one?
The reason i ask is this, i'm writing a WPF app, and im using IoC.Get to load my viewmodels initially, now due to a redesign i would like the ability to create a whole new set of those views, so my parent viewmodel looks similar to this:
public ProjectContainerViewModel()
{
_containersListModel = IoC.Get<ContainersListViewModel>();
_orderedItemListModel = IoC.Get<ItemsOrderedViewModel>();
_packageListModel = IoC.Get<PackagesListViewModel>();
}
Could i instead create new instances here using _containersListModel = new ContainersListModel(). and from then on get that same instance with IOC?
EDIT: I'm using the bootstrapper found here: https://caliburnmicro.codeplex.com/wikipage?title=Customizing%20The%20Bootstrapper
Which defines the container, i'm also marking my viewmodels with [Export(typeof(ContainersListViewModel))] at the start of the class.
IoC.Get(), or the same instance over and over (singleton), depending on the way the implementation was bound. 1) What are you using for your DI container (e.g. Caliburn.Micro'sSimpleContaineror something else)? 2) How are you creating the container's bindings (or are you letting it resolve "automatically")? - SteveIoC.Get()again to get a new one. - Steve