Permalink
Browse files

small refactoring

  • Loading branch information...
1 parent 9aa2d38 commit 706e88102400d54d639d5e991b6d9be30e509256 @serbrech serbrech committed Apr 24, 2012
Showing with 20 additions and 28 deletions.
  1. +20 −28 Unity.SolrNetIntegration/SolrNetContainerConfiguration.cs
@@ -74,13 +74,15 @@ public class SolrNetContainerConfiguration {
string connectionId = GetCoreConnectionId(core.Id);
container.RegisterType<ISolrConnection, SolrConnection>(connectionId, new InjectionConstructor(core.Url));
if (!container.IsRegistered(typeof (ISolrOperations<>).MakeGenericType(core.DocumentType))) {
- RegisterSolrQueryExecuter(core, container, isNamed : false);
- RegisterBasicOperations(core, container, isNamed : false);
- RegisterSolrOperations(core, container, isNamed : false);
+ RegisterAll(core, container, isNamed : false);
}
- RegisterSolrQueryExecuter(core, container);
- RegisterBasicOperations(core, container);
- RegisterSolrOperations(core, container);
+ RegisterAll(core, container);
+ }
+
+ private static void RegisterAll(SolrCore core, IUnityContainer container, bool isNamed = true) {
+ RegisterSolrQueryExecuter(core, container, isNamed);
+ RegisterBasicOperations(core, container, isNamed);
+ RegisterSolrOperations(core, container, isNamed);
}
private static void RegisterSolrOperations(SolrCore core, IUnityContainer container, bool isNamed = true) {
@@ -104,29 +106,19 @@ public class SolrNetContainerConfiguration {
var ISolrQueryExecuter = typeof (ISolrQueryExecuter<>).MakeGenericType(core.DocumentType);
var registrationId = isNamed ? core.Id : null;
string coreConnectionId = GetCoreConnectionId(core.Id);
- container.RegisterType(
- ISolrBasicOperations, SolrBasicServer, registrationId,
- new InjectionConstructor(
- new ResolvedParameter(typeof (ISolrConnection), coreConnectionId),
- new ResolvedParameter(ISolrQueryExecuter, registrationId),
- new ResolvedParameter(typeof (ISolrDocumentSerializer<>).MakeGenericType(core.DocumentType)),
- new ResolvedParameter(typeof (ISolrSchemaParser)),
- new ResolvedParameter(typeof (ISolrHeaderResponseParser)),
- new ResolvedParameter(typeof (ISolrQuerySerializer)),
- new ResolvedParameter(typeof (ISolrDIHStatusParser)),
- new ResolvedParameter(typeof (ISolrExtractResponseParser))));
- container.RegisterType(
- ISolrBasicReadOnlyOperations, SolrBasicServer, registrationId,
- new InjectionConstructor(
- new ResolvedParameter(typeof (ISolrConnection), coreConnectionId),
- new ResolvedParameter(ISolrQueryExecuter, registrationId),
- new ResolvedParameter(typeof (ISolrDocumentSerializer<>).MakeGenericType(core.DocumentType)),
- new ResolvedParameter(typeof (ISolrSchemaParser)),
- new ResolvedParameter(typeof (ISolrHeaderResponseParser)),
- new ResolvedParameter(typeof (ISolrQuerySerializer)),
- new ResolvedParameter(typeof (ISolrDIHStatusParser)),
- new ResolvedParameter(typeof (ISolrExtractResponseParser))));
+ var injectionParameters = new InjectionConstructor(
+ new ResolvedParameter(typeof(ISolrConnection), coreConnectionId),
+ new ResolvedParameter(ISolrQueryExecuter, registrationId),
+ new ResolvedParameter(typeof(ISolrDocumentSerializer<>).MakeGenericType(core.DocumentType)),
+ new ResolvedParameter(typeof(ISolrSchemaParser)),
+ new ResolvedParameter(typeof(ISolrHeaderResponseParser)),
+ new ResolvedParameter(typeof(ISolrQuerySerializer)),
+ new ResolvedParameter(typeof(ISolrDIHStatusParser)),
+ new ResolvedParameter(typeof(ISolrExtractResponseParser)));
+
+ container.RegisterType(ISolrBasicOperations, SolrBasicServer, registrationId, injectionParameters);
+ container.RegisterType(ISolrBasicReadOnlyOperations, SolrBasicServer, registrationId, injectionParameters);
}
private static void RegisterSolrQueryExecuter(SolrCore core, IUnityContainer container, bool isNamed = true) {

0 comments on commit 706e881

Please sign in to comment.