/// <summary> /// Registers a new core in the container. /// This method is meant to be used after the facility initialization /// </summary> private static void RegisterCore(SolrCore core, ContainerBuilder builder) { var coreConnectionId = core.Id + typeof(SolrConnection); builder.RegisterType(typeof(SolrConnection)) .Named(coreConnectionId, typeof(ISolrConnection)) .WithParameters(new[] { new NamedParameter("serverURL", core.Url) }); var ISolrQueryExecuter = typeof(ISolrQueryExecuter <>).MakeGenericType(core.DocumentType); var SolrQueryExecuter = typeof(SolrQueryExecuter <>).MakeGenericType(core.DocumentType); builder.RegisterType(SolrQueryExecuter) .Named(core.Id + SolrQueryExecuter, ISolrQueryExecuter) .WithParameters(new[] { new ResolvedParameter((p, c) => p.Name == "connection", (p, c) => c.ResolveNamed(coreConnectionId, typeof(ISolrConnection))), }); var ISolrBasicOperations = typeof(ISolrBasicOperations <>).MakeGenericType(core.DocumentType); var ISolrBasicReadOnlyOperations = typeof(ISolrBasicReadOnlyOperations <>).MakeGenericType(core.DocumentType); var SolrBasicServer = typeof(SolrBasicServer <>).MakeGenericType(core.DocumentType); builder.RegisterType(SolrBasicServer) .Named(core.Id + SolrBasicServer, ISolrBasicOperations) .WithParameters(new[] { new ResolvedParameter((p, c) => p.Name == "connection", (p, c) => c.ResolveNamed(coreConnectionId, typeof(ISolrConnection))), new ResolvedParameter((p, c) => p.Name == "queryExecuter", (p, c) => c.ResolveNamed(core.Id + SolrQueryExecuter, ISolrQueryExecuter)) }); builder.RegisterType(SolrBasicServer) .Named(core.Id + SolrBasicServer, ISolrBasicReadOnlyOperations) .WithParameters(new[] { new ResolvedParameter((p, c) => p.Name == "connection", (p, c) => c.ResolveNamed(coreConnectionId, typeof(ISolrConnection))), new ResolvedParameter((p, c) => p.Name == "queryExecuter", (p, c) => c.ResolveNamed(core.Id + SolrQueryExecuter, ISolrQueryExecuter)) }); var ISolrOperations = typeof(ISolrOperations <>).MakeGenericType(core.DocumentType); var ISolrReadOnlyOperations = typeof(ISolrReadOnlyOperations <>).MakeGenericType(core.DocumentType); var SolrServer = typeof(SolrServer <>).MakeGenericType(core.DocumentType); builder.RegisterType(SolrServer) .Named(core.Id, ISolrOperations) .As(ISolrOperations) .WithParameters(new[] { new ResolvedParameter((p, c) => p.Name == "basicServer", (p, c) => c.ResolveNamed(core.Id + SolrBasicServer, ISolrBasicOperations)), }); builder.RegisterType(SolrServer) .Named(core.Id, ISolrReadOnlyOperations) .As(ISolrReadOnlyOperations) .WithParameters(new[] { new ResolvedParameter((p, c) => p.Name == "basicServer", (p, c) => c.ResolveNamed(core.Id + SolrBasicServer, ISolrBasicOperations)), }); }
/// <summary> /// Registers a new core in the container. /// This method is meant to be used after the facility initialization /// </summary> private static void RegisterCore(SolrCore core, ContainerBuilder builder) { var coreConnectionId = core.Id + typeof (SolrConnection); builder.RegisterType(typeof (SolrConnection)) .Named(coreConnectionId, typeof (ISolrConnection)) .WithParameters(new[] { new NamedParameter("serverURL", core.Url) }); var ISolrQueryExecuter = typeof (ISolrQueryExecuter<>).MakeGenericType(core.DocumentType); var SolrQueryExecuter = typeof (SolrQueryExecuter<>).MakeGenericType(core.DocumentType); builder.RegisterType(SolrQueryExecuter) .Named(core.Id + SolrQueryExecuter, ISolrQueryExecuter) .WithParameters(new[] { new ResolvedParameter((p, c) => p.Name == "connection", (p, c) => c.ResolveNamed(coreConnectionId, typeof (ISolrConnection))), }); var ISolrBasicOperations = typeof (ISolrBasicOperations<>).MakeGenericType(core.DocumentType); var ISolrBasicReadOnlyOperations = typeof (ISolrBasicReadOnlyOperations<>).MakeGenericType(core.DocumentType); var SolrBasicServer = typeof (SolrBasicServer<>).MakeGenericType(core.DocumentType); builder.RegisterType(SolrBasicServer) .Named(core.Id + SolrBasicServer, ISolrBasicOperations) .WithParameters(new[] { new ResolvedParameter((p, c) => p.Name == "connection", (p, c) => c.ResolveNamed(coreConnectionId, typeof (ISolrConnection))), new ResolvedParameter((p, c) => p.Name == "queryExecuter", (p, c) => c.ResolveNamed(core.Id + SolrQueryExecuter, ISolrQueryExecuter)) }); builder.RegisterType(SolrBasicServer) .Named(core.Id + SolrBasicServer, ISolrBasicReadOnlyOperations) .WithParameters(new[] { new ResolvedParameter((p, c) => p.Name == "connection", (p, c) => c.ResolveNamed(coreConnectionId, typeof (ISolrConnection))), new ResolvedParameter((p, c) => p.Name == "queryExecuter", (p, c) => c.ResolveNamed(core.Id + SolrQueryExecuter, ISolrQueryExecuter)) }); var ISolrOperations = typeof (ISolrOperations<>).MakeGenericType(core.DocumentType); var ISolrReadOnlyOperations = typeof (ISolrReadOnlyOperations<>).MakeGenericType(core.DocumentType); var SolrServer = typeof (SolrServer<>).MakeGenericType(core.DocumentType); builder.RegisterType(SolrServer) .Named(core.Id, ISolrOperations) .As(ISolrOperations) .WithParameters(new[] { new ResolvedParameter((p, c) => p.Name == "basicServer", (p, c) => c.ResolveNamed(core.Id + SolrBasicServer, ISolrBasicOperations)), }); builder.RegisterType(SolrServer) .Named(core.Id, ISolrReadOnlyOperations) .As(ISolrReadOnlyOperations) .WithParameters(new[] { new ResolvedParameter((p, c) => p.Name == "basicServer", (p, c) => c.ResolveNamed(core.Id + SolrBasicServer, ISolrBasicOperations)), }); }