title: StructureMap: Injecting a primitive property in a base class
body: <p>Related to this <a href="https://stackoverflow.com/questions/5729847/injecting-a-primitive-property-in-a-base-class-with-castle-windsor">question</a>, but this question is about StructureMap.</p>
  
  <p>I have got the following interface definition:</p>
  
  <pre><code>public interface ICommandHandler
  {
      ILogger Logger { get; set; }
      bool SendAsync { get; set; }
  }
  </code></pre>
  
  <p>I have multiple implementations that implement <code>ICommandHandler</code> and need to be resolved. I want to automatically inject these two properties in instances that implement <code>ICommandHandler</code>.</p>
  
  <p>I found a way to do inject the <code>ILogger</code> by letting all implementations inherit from a base type and the <code>[SetterProperty]</code> attribute:</p>
  
  <pre><code>public abstract class BaseCommandHandler : ICommandHandler
  {
      [SetterProperty]
      public ILogger Logger { get; set; }
  
      public bool SendAsync { get; set; }
  }
  </code></pre>
  
  <p>This however, doesn't help me with injecting the primitive <code>bool</code> type in all implementations.</p>
  
  <p>The command handlers implement a generic interface that inherits from the base interface:</p>
  
  <pre><code>public interface ICommandHandler&lt;TCommand&gt; : ICommandHandler
      where TCommand : Command
  {
       void Handle(TCommand command);
  }
  </code></pre>
  
  <p>Here is my current configuration:</p>
  
  <pre><code>var container = new Container();
  
  container.Configure(r =&gt; r
      .For&lt;ICommandHandler&lt;CustomerMovedCommand&gt;&gt;()
      .Use&lt;CustomerMovedHandler&gt;()
      .SetProperty(handler =&gt;
      { 
          handler.SendAsync = true;
      }));
  
  container.Configure(r =&gt; r
      .For&lt;ICommandHandler&lt;ProcessOrderCommand&gt;&gt;()
      .Use&lt;ProcessOrderHandler&gt;()
      .SetProperty(handler =&gt;
      { 
          handler.SendAsync = true;
      }));
  
  container.Configure(r =&gt; r
      .For&lt;ICommandHandler&lt;CustomerLeftCommand&gt;&gt;()
      .Use&lt;CustomerLeftHandler&gt;()
      .SetProperty(handler =&gt;
      { 
          handler.SendAsync = true;
      }));
  
  // etc. etc. etc.
  </code></pre>
  
  <p>As you can see, I set the property for each and every configuration, which is quite cumbersome (however, it is pretty nice that the <code>SetProperty</code> accepts a <code>Action&lt;T&gt;</code> delegate).</p>
  
  <p>What ways are there to do this more efficiently with StructureMap?</p>