Skip to content
Discussion options

You must be logged in to vote

So first of all any time you call GetContainer() you're working with the underlying container (i.e. Unity Container or DryIoc). TryResolve was never part of Prism's API.

That said what I would recommend is something like the following:

containerRegistry.RegisterSingleton<IBroker>(c => 
{
    var broker = c.Resolve<GreefaBroker>();
    broker.Init(lSettings.From);
    return broker;
});

You do not explicitly need a registration for GreefaBroker as it is a concrete type, this means that by default the container will resolve this as a Transient. Using the delegate / factory extension as shown above you can initialize the instance before returning it for the IBroker registration

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@josdemmers
Comment options

Comment options

You must be logged in to vote
1 reply
@josdemmers
Comment options

Answer selected by josdemmers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
WPF
Labels
None yet
3 participants