Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to get details about the request that's being made to the object, use the overload <code>WithConstructorArgument(string, Func&lt;IContext, object&gt;)</code>. You can use the supplied <code>IContext</code> to look for the assembly name (use the debugger to look around, it sounds like your layout might be quite complex so I can't offer specific code).</p> <p>As an example of how to use this:</p> <pre><code>//get the full name of the requested object Bind&lt;IFoo&gt;() .To&lt;Foo&gt;() .WithConstructorArgument("bar", c =&gt; c.Request.FullName); </code></pre> <p>However, it sounds to me like you're looking at it from the wrong angle. If I read your question correctly, it sounds like you have a class that scans your assemblies and then decides what to inject instead of letting Ninject do it for you. I assume this is a leftover from when you weren't using DI?</p> <p>I'd take a look at using contextual binding with the <code>WhenInjectedInto</code> method or custom attributes to inject the specific <code>IHelper</code> that you want into the constructor. See here: <a href="https://github.com/ninject/ninject/wiki/Contextual-Binding" rel="nofollow">https://github.com/ninject/ninject/wiki/Contextual-Binding</a></p> <p>The linked page actually has an example of doing something similar that may work for you:</p> <pre><code>Bind&lt;IWarrior&gt;() .To&lt;Samurai&gt;() .When(request =&gt; request.Target.Type.Namespace.StartsWith("Samurais.Climbing")); </code></pre> <p>I'd probably still use <code>WhenInjectedInto</code> or attributes though so you don't have any "magic strings" in case you refactor your namespaces later.</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