Ejemplo n.º 1
0
        /// <summary>
        /// Add SolrExpress services
        /// </summary>
        /// <param name="container">Container used in SimpleInjector engine</param>
        /// <returns>Container used in SimpleInjector engine</returns>
        public static IKernel AddSolrExpress <TDocument>(this IKernel container, Action <SolrExpressBuilder <TDocument> > builder)
            where TDocument : Document
        {
            var solrExpressServiceProvider = new SolrExpressServiceProvider <TDocument>();
            var solrExpressBuilder         = new SolrExpressBuilder <TDocument>(solrExpressServiceProvider);

            builder.Invoke(solrExpressBuilder);

            container.Bind <ISolrExpressServiceProvider <TDocument> >().ToMethod(context => solrExpressServiceProvider).InSingletonScope();
            container.Bind <DocumentCollection <TDocument> >().To <DocumentCollection <TDocument> >().InSingletonScope();

            CoreDependecyInjection.Configure(solrExpressServiceProvider, solrExpressBuilder.Options);

            return(container);
        }
        /// <summary>
        /// Add SolrExpress services
        /// </summary>
        /// <param name="container">Container used in SimpleInjector engine</param>
        /// <returns>Container used in SimpleInjector engine</returns>
        public static ContainerBuilder AddSolrExpress <TDocument>(this ContainerBuilder container, Action <SolrExpressBuilder <TDocument> > builder)
            where TDocument : Document
        {
            var solrExpressServiceProvider = new SolrExpressServiceProvider <TDocument>();
            var solrExpressBuilder         = new SolrExpressBuilder <TDocument>(solrExpressServiceProvider);

            builder.Invoke(solrExpressBuilder);

            container.Register <ISolrExpressServiceProvider <TDocument> >(q => solrExpressServiceProvider).SingleInstance();
            container.RegisterType <DocumentCollection <TDocument> >().SingleInstance();

            CoreDependecyInjection.Configure(solrExpressServiceProvider, solrExpressBuilder.Options);

            return(container);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add SolrExpress services
        /// </summary>
        /// <param name="serviceCollection">Service collection used in .Net Core DI engine</param>
        /// <returns>Service collection used in .Net Core DI engine</returns>
        public static IServiceCollection AddSolrExpress <TDocument>(this IServiceCollection serviceCollection, Action <SolrExpressBuilder <TDocument> > builder)
            where TDocument : Document
        {
            var solrExpressServiceProvider = new SolrExpressServiceProvider <TDocument>();
            var solrExpressBuilder         = new SolrExpressBuilder <TDocument>(solrExpressServiceProvider);

            builder.Invoke(solrExpressBuilder);

            serviceCollection
            .AddSingleton <ISolrExpressServiceProvider <TDocument> >(solrExpressServiceProvider)
            .AddSingleton <DocumentCollection <TDocument> >();

            CoreDependecyInjection.Configure(solrExpressServiceProvider, solrExpressBuilder.Options);

            return(serviceCollection);
        }