Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Full disclosure: I've never used StructureMap before, so I could be misunderstanding how it's intended to be used. But as near as I can tell, either this use-case is intentionally not supported by StructureMap, or it's a bug. </p> <p>But first, you have one error; you need to fix your <code>id</code> to match your <code>.ToUpper</code> call (i.e. it should be <code>var id = "TESTEVENT";</code>, not <code>var id = "TestEvent";</code>). </p> <p>Once you've done that, though, it still doesn't work. Inspecting the source code, it's clear why. The constructor of the types are inspected (in this case, <code>TestEvent</code>) and if any constructor declares a parameter whose type is "simple" (i.e. primitives, strings, etc.) then that constructor is categorically disqualified from participating in the <code>.GetInstance</code> behavior. </p> <p>Specifically, if you examine <code>StructureMap.Graph.PluginFamily.discoverImplicitInstances()</code>:</p> <pre><code>private void discoverImplicitInstances() { _pluggedTypes.Each((key, plugin) =&gt; { if (!plugin.CanBeAutoFilled) return; if (hasInstanceWithPluggedType(plugin)) return; ConfiguredInstance instance = new ConfiguredInstance(plugin.PluggedType).WithName(key); FillInstance(instance); }); } </code></pre> <p>It's that first line in the lambda that is the culprit:</p> <pre><code>if (!plugin.CanBeAutoFilled) return; </code></pre> <p>That's the line that is disqualifying your constructor (and thus your type). Strings can't be "auto-filled" since you can't just new one up, and they wouldn't be registered for injection.</p> <p>If you comment that line out your code will now work. What puzzles me is that while I understand why your constructor couldn't be <em>implicitly</em> created, the code as written seems to also disqualify code from working when you are passing <em>explicit</em> arguments as you've done.</p> <p>Maybe someone with more experience with StructureMap will be able to offer more expert guidance, but hopefully this was better than nothing.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. 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