Note that there are some explanatory texts on larger screens.

plurals
  1. POCan someone explain the magic going on in Prism's resolve<> method?
    primarykey
    data
    text
    <p>I've got a <strong>CustomersModule.cs</strong> with the following Initialize() method:</p> <pre><code>public void Initialize() { container.RegisterType&lt;ICustomersRepository, CustomersRepository&gt;(new ContainerControlledLifetimeManager()); CustomersPresenter customersPresenter = this.container.Resolve&lt;CustomersPresenter&gt;(); } </code></pre> <p>The <strong>class I resolve</strong> from the container looks like this:</p> <pre><code>class CustomersPresenter { private CustomersView view; private ICustomersRepository customersRespository; public CustomersPresenter(CustomersView view, ICustomersRepository customersRepository, TestWhatever testWhatever) { this.view = view; this.customersRespository = customersRepository; } } </code></pre> <p>The <strong>TestWhatever</strong> class is just a <strong>dummy class</strong> I created:</p> <pre><code>public class TestWhatever { public string Title { get; set; } public TestWhatever() { Title = "this is the title"; } } </code></pre> <p>Yet the container <strong>happily resolves</strong> <code>CustomersPresenter</code> even though <strong>I never registered it</strong>, and also the container <strong>somehow finds</strong> TestWhatever, instantiates it, and injects it into <code>CustomersPresenter</code>.</p> <p><strong>I was quite surprised to realize this</strong> since I couldn't find anywhere in the Prism documentation which explicitly stated that the container was so automatic.</p> <p>So this is great, but it what else is the container doing that I don't know about i.e. what else can it do that I don't know about? <strong>For example, can I inject classes from other modules and if the modules happen to be loaded the container will inject them, and if not, it will inject a null?</strong> </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload