Search code examples
wpfunity-containerprismprism-7

How to set different lifetime managers in Prism 7 with Unity container


In older versions of Prism I was able to do this from UnityBootstrapper class

    protected override void ConfigureContainer()
    {
        base.ConfigureContainer();
        Container.RegisterType<IViewDragService, ViewDragService>(new HierarchicalLifetimeManager());
    }

What would be equivalent of this code for Prism 7 when unity container is used ?


Solution

  • You can use GetContainer on the container abstraction you receive from prism to get the actual IUnityContainer:

    containerRegistry.GetContainer().RegisterType<IViewDragService, ViewDragService>(new HierarchicalLifetimeManager());