we are making a Xamarin application that uses PRISM library with DryIoc for DI. We have some services registered as Transient or Scoped in a .NET Core dependency injection simple IServiceCollection, which we adapt onto DryIoc.
The problem that we encounter is that (even if we register a type as Transient), when the container injects dependencies to new Views in the constructor, it injects every time the same instance.
In our overriden implementation of PrismApplication.CreateContainer
, we only call base.CreateContainer
, and add the .NET Core collection with WithDependencyInjectionAdapter
method.
The goal is to create a new instance of the dependencies (a new DbContext
for example) in each view creation. How can we achieve that?