title: MvcSiteMapProvider - builder set registration using structuremap moved to a separate method?
body: <p>I have an MVC app for which I am using MvcSiteMapProvider to display breadcrumbs. I have read through <a href="https://github.com/maartenba/MvcSiteMapProvider/wiki/Multiple-Sitemaps-in-One-Application" rel="nofollow">https://github.com/maartenba/MvcSiteMapProvider/wiki/Multiple-Sitemaps-in-One-Application</a> and gotten multiple sitemaps to work correctly in my application. I'm using StructureMap as the DI container for MvcSiteMapProvider.</p>
  
  <p>In the example above, two SiteMapBuilder class instances are manually created and then they are both injected into the SiteMapBuilderSetStrategy constructor together.</p>
  
  <p>I have about a dozen sitemaps in use. This number my change in the future. In order to minimize the maintenance involved, I would like to create a method call that will handle properly injecting a SiteMapBuilder instance into the SiteMapBuilderSetStrategy constructor.</p>
  
  <p>so I would like to go from something like this</p>
  
  <pre><code>//instance 1
  var source1 = this.For&lt;IXmlSource&gt;()
              .Use&lt;FileXmlSource&gt;()
              .Ctor&lt;string&gt;"fileName").Is([filepath to sitemap file]));
  
  var provider1 = this.For&lt;ISiteMapNodeProvider&gt;()
              .Use&lt;XmlSiteMapNodeProvider&gt;()
              .Ctor&lt;bool&gt;("includeRootNode").Is(true)
              .Ctor&lt;bool&gt;("useNestedDynamicNodeRecursion").Is(false)
              .Ctor&lt;IXmlSource&gt;().Is(source1);
  
  var builder1 = this.For&lt;ISiteMapBuilder&gt;()
              .Use&lt;SiteMapBuilder&gt;()
              .Ctor&lt;ISiteMapNodeProvider&gt;().Is(provider1);
  
  //instance 2
  var source2 = this.For&lt;IXmlSource&gt;()
              .Use&lt;FileXmlSource&gt;()
              .Ctor&lt;string&gt;("fileName").Is([filepath to sitemap file]));
  
  var provider2 = this.For&lt;ISiteMapNodeProvider&gt;()
              .Use&lt;XmlSiteMapNodeProvider&gt;()
              .Ctor&lt;bool&gt;("includeRootNode").Is(true)
              .Ctor&lt;bool&gt;("useNestedDynamicNodeRecursion").Is(false)
              .Ctor&lt;IXmlSource&gt;().Is(source2);
  
  var builder1 = this.For&lt;ISiteMapBuilder&gt;()
              .Use&lt;SiteMapBuilder&gt;()
              .Ctor&lt;ISiteMapNodeProvider&gt;().Is(provider2);
  
  //inject
  this.For&lt;ISiteMapBuilderSetStrategy&gt;()
              .Use&lt;SiteMapBuilderSetStrategy&gt;()
              .EnumerableOf&lt;ISiteMapBuilderSet&gt;()
              .Contains(x =&gt;
              {
                  x.Type&lt;SiteMapBuilderSet&gt;()
                     .Ctor&lt;string&gt;("instanceName").Is("instance 1")
                     .Ctor&lt;bool&gt;("securityTrimmingEnabled").Is(true)
                     .Ctor&lt;bool&gt;("enableLocalization").Is(false)
                     .Ctor&lt;ISiteMapBuilder&gt;().Is(builder1)
                     ;
                 x.Type&lt;SiteMapBuilderSet&gt;()
                     .Ctor&lt;string&gt;("instanceName").Is("instance 2")
                     .Ctor&lt;bool&gt;("securityTrimmingEnabled").Is(true)
                     .Ctor&lt;bool&gt;("enableLocalization").Is(false)
                     .Ctor&lt;ISiteMapBuilder&gt;().Is(builder2)
                     ;
              });
  </code></pre>
  
  <p>to something like this, that I would be able to call from the Registry constructor.</p>
  
  <pre><code>methodized(string filePath, string instanceName)
      {
          var source = this.For&lt;IXmlSource&gt;().Add&lt;FileXmlSource&gt;()
              .Ctor&lt;string&gt;("fileName").Is(filePath);
          var provider = this.For&lt;ISiteMapNodeProvider&gt;()
              .Add&lt;XmlSiteMapNodeProvider&gt;()
              .Ctor&lt;bool&gt;("includeRootNode").Is(true)
              .Ctor&lt;bool&gt;("useNestedDynamicNodeRecursion").Is(false)
              .Ctor&lt;IXmlSource&gt;().Is(source);
          var builder = this.For&lt;ISiteMapBuilder&gt;().Add&lt;SiteMapBuilder&gt;()
              .Ctor&lt;ISiteMapNodeProvider&gt;().Is(provider);
  
  
          this.For&lt;ISiteMapBuilderSetStrategy&gt;().Add&lt;SiteMapBuilderSetStrategy&gt;()
              .EnumerableOf&lt;ISiteMapBuilderSet&gt;().Contains(x =&gt;
              {
                  x.Type&lt;SiteMapBuilderSet&gt;()
                     .Ctor&lt;string&gt;("instanceName").Is(instanceName)
                     .Ctor&lt;bool&gt;("securityTrimmingEnabled").Is(true)
                     .Ctor&lt;bool&gt;("enableLocalization").Is(false)
                     .Ctor&lt;ISiteMapBuilder&gt;().Is(builder)
                     ;
              });
      }
  </code></pre>
  
  <p>I'm not familiar with StructureMap, nor am I having much luck creating said method. Any suggestions would be appreciated. Thank you in advance.</p>