Using StructureMap with Solrnet – updated

The implementation has now been updated to allow for multi-core instances. Which can be set up in your Bootstrapper like this:

var solr = (SolrConfigurationSection)ConfigurationManager.GetSection(“solr”);
var solrServers = solr.SolrServers;
ObjectFactory.Initialize(
x => x.AddRegistry(new SolrNetRegistry(solrServers))
);

You’re app config should look like the the following:

<configuration>
<configSections>
<section name="solr"
    type="StructureMap.SolrNetIntegration.Config.SolrConfigurationSection, SolrNet" />
</configSections>
<solr>
<server id="myobject" url="http://localhost:8080/solr/"
documentType="Your.Objects.Name, Your.Objects.Namespace" />
</solr>
</configuration>
Advertisements

Using StructureMap with SolrNet

SolrNet is a great .NET library for querying and updating a Solr instance. I’ve been using it recently as part of a project in which we were using StructureMap as our IOC framework (like most of our projects). It has its own built in IOC  based on the Common Service Locator Interface (Microsoft.Practices.ServiceLocation) as well as support for Windsor and Ninject.

As I didn’t want to switch our IOC Framework I decided to write a registry class. It’s now very simple to register  the container using the following line in your bootstrapper.

ObjectFactory.Initialize(
x => x.AddRegistry(
new SolrNetRegistry("http://localhost:8893/solr")
)
);

Its now included in the git master and the binaries should be available shortly.

Updated: The structuremap adapter now allows for multicore configuration