Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>ASP.NET has a type of Dependency Injection built-in.</p> <p>What that means is that instead of having a hard reference to a specific class, the controller has references to interfaces. The <code>Resolver</code> is then configured to return a certain type when an instance is requested. For example (sample code, I don't know the exact methodnames)</p> <pre><code>Resolver.Bind&lt;IActionInvoker&gt;().To&lt;ActionInvoker&gt;(); // if an IActionInvoker is requested, return an instance of type ActionInvoker. </code></pre> <p>After this configuration a call to <code>GetService</code> will get you an instance of <code>ActionInvoker</code></p> <p>So, to answer your questions:</p> <ol> <li>How the IActionInvoker interface is instantiated over here, and returned by ActionInvoker property ?</li> </ol> <blockquote> <blockquote> <p>by configuring the resolver in before hand, the resolver knows which type to create and return</p> </blockquote> </blockquote> <ol> <li>Does the reference to the property returns an object of AsyncControllerActionInvoker class, so that we can use that object to make a call to InvokeAction(ControllerContext, actionName) method.</li> </ol> <blockquote> <blockquote> <p>Yes and no. Yes the property will assure that you have an object which implements <code>IActionInvoker</code> which you can use to call <code>InvokeAction</code>. And no, your not guaranteed that it is of type <code>IAsyncActionInvoker</code> (depends on the configuration of the resolver)</p> </blockquote> </blockquote> <ol> <li>What the does Resolver.GetService() and Resolver.GetService() do ?</li> </ol> <p>They ask the resolver to instantiate an object that implements the given Interface. The resolver will look up the interfaces in its configuration, instantiate the appropriate object and return it to the caller.</p> <p>Dpendency Injection is a way to decouple your code. Since you only reference the interface, you have no hard dependencies and you could just reconfigure the DI container (<code>Resolver</code> in this case) and you will be using another class, without your client class ever knowing about it.</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.
    1. VO
      singulars
      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