예제 #1
0
        /// <summary>
        /// Use SolrExpress services implemented in SOLR 4
        /// </summary>
        /// <param name="solrExpressBuilder">Builder to control SolrExpress behavior</param>
        /// <returns>Builder to control SolrExpress behavior</returns>
        public static SolrExpressBuilder <TDocument> UseSolrFake <TDocument>(this SolrExpressBuilder <TDocument> solrExpressBuilder)
            where TDocument : Document
        {
            solrExpressBuilder
            .ServiceProvider
            .AddTransient <IAnyParameter, FakeAnyParameter>()
            .AddTransient <IAtomicUpdate <TDocument> >(new Mock <IAtomicUpdate <TDocument> >().Object)
            .AddTransient <IAtomicDelete>(new Mock <IAtomicDelete>().Object)
            .AddTransient <IBoostParameter <TDocument> >(new Mock <IBoostParameter <TDocument> >().Object)
            .AddTransient <IDefaultFieldParameter <TDocument> >(new Mock <IDefaultFieldParameter <TDocument> >().Object)
            .AddTransient <IFacetFieldParameter <TDocument> >(new Mock <IFacetFieldParameter <TDocument> >().Object)
            .AddTransient <IFacetLimitParameter <TDocument> >(new Mock <IFacetLimitParameter <TDocument> >().Object)
            .AddTransient <IFacetQueryParameter <TDocument> >(new Mock <IFacetQueryParameter <TDocument> >().Object)
            .AddTransient <IFacetRangeParameter <TDocument> >(new Mock <IFacetRangeParameter <TDocument> >().Object)
            .AddTransient <IFacetSpatialParameter <TDocument> >(new Mock <IFacetSpatialParameter <TDocument> >().Object)
            .AddTransient <IFacetsResult <TDocument> >(new Mock <IFacetsResult <TDocument> >().Object)
            .AddTransient <IFieldsParameter <TDocument> >(new Mock <IFieldsParameter <TDocument> >().Object)
            .AddTransient <IFilterParameter <TDocument> >(new Mock <IFilterParameter <TDocument> >().Object)
            .AddTransient <ILimitParameter <TDocument> >(new Mock <ILimitParameter <TDocument> >().Object)
            .AddTransient <IMinimumShouldMatchParameter <TDocument> >(new Mock <IMinimumShouldMatchParameter <TDocument> >().Object)
            .AddTransient <IOffsetParameter <TDocument> >(new Mock <IOffsetParameter <TDocument> >().Object)
            .AddTransient <IQueryFieldParameter <TDocument> >(new Mock <IQueryFieldParameter <TDocument> >().Object)
            .AddTransient <IQueryParameter <TDocument> >(new Mock <IQueryParameter <TDocument> >().Object)
            .AddTransient <IQueryParserParameter <TDocument> >(new Mock <IQueryParserParameter <TDocument> >().Object)
            .AddTransient <ISearchItemCollection <TDocument> >(new FakeSearchItemCollection <TDocument>())
            .AddTransient <ISortParameter <TDocument> >(new Mock <ISortParameter <TDocument> >().Object)
            .AddTransient <ISortRandomlyParameter <TDocument> >(new Mock <ISortRandomlyParameter <TDocument> >().Object)
            .AddTransient <ISpatialFilterParameter <TDocument> >(new Mock <ISpatialFilterParameter <TDocument> >().Object)
            .AddTransient <IStandardQueryParameter <TDocument> >(new Mock <IStandardQueryParameter <TDocument> >().Object)
            .AddTransient <ISystemParameter <TDocument> >(new Mock <ISystemParameter <TDocument> >().Object)
            .AddTransient <IWriteTypeParameter <TDocument> >(new Mock <IWriteTypeParameter <TDocument> >().Object);

            return(solrExpressBuilder);
        }
        public static Container AddSolrExpressFake <TDocument>(this Container container, Action <SolrExpressBuilder <TDocument> > builder)
            where TDocument : Document
        {
            var solrExpressServiceProvider = (ISolrExpressServiceProvider <TDocument>) new SolrExpressServiceProvider <TDocument>();
            var solrExpressBuilder         = new SolrExpressBuilder <TDocument>(solrExpressServiceProvider);

            builder.Invoke(solrExpressBuilder);

            container.Register <ISolrExpressServiceProvider <TDocument> >(() => solrExpressServiceProvider, Lifestyle.Singleton);
            container.Register <DocumentCollection <TDocument> >(Lifestyle.Singleton);

            solrExpressServiceProvider
            .AddSingleton(solrExpressBuilder.Options)
            .AddTransient(solrExpressServiceProvider);

            var solrConnection    = new FakeSolrConnection <TDocument>();
            var expressionBuilder = new ExpressionBuilder <TDocument>(solrExpressBuilder.Options, solrConnection);

            expressionBuilder.LoadDocument();

            solrExpressServiceProvider
            .AddTransient(expressionBuilder)
            .AddTransient <DocumentSearch <TDocument> >()
            .AddTransient <DocumentUpdate <TDocument> >()
            .AddTransient <SearchResultBuilder <TDocument> >()
            .AddTransient <SearchQuery <TDocument> >()
            .AddTransient <ISolrConnection>(solrConnection)
            .AddTransient <IDocumentResult <TDocument>, DocumentResult <TDocument> >()
            .AddTransient <IChangeDynamicFieldBehaviour <TDocument>, ChangeDynamicFieldBehaviour <TDocument> >();

            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 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);
        }
예제 #5
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);
        }
예제 #6
0
        /// <summary>
        /// Use SolrExpress services implemented in SOLR 5
        /// </summary>
        /// <param name="solrExpressBuilder">Builder to control SolrExpress behavior</param>
        /// <returns>Builder to control SolrExpress behavior</returns>
        public static SolrExpressBuilder <TDocument> UseSolr5 <TDocument>(this SolrExpressBuilder <TDocument> solrExpressBuilder)
            where TDocument : Document
        {
            solrExpressBuilder
            .ServiceProvider
            .AddTransient <IAnyParameter, AnyParameter>()
            .AddTransient <IAtomicDelete, AtomicDelete <TDocument> >()
            .AddTransient <IAtomicUpdate <TDocument>, AtomicUpdate <TDocument> >()
            .AddTransient <IBoostParameter <TDocument>, BoostParameter <TDocument> >()
            .AddTransient <ICursorMarkParameter, CursorMarkParameter>()
            .AddTransient <IDefaultFieldParameter <TDocument>, DefaultFieldParameter <TDocument> >()
            .AddTransient <IFacetFieldParameter <TDocument>, FacetFieldParameter <TDocument> >()
            .AddTransient <IFacetLimitParameter <TDocument>, FacetLimitParameter <TDocument> >()
            .AddTransient <IFacetQueryParameter <TDocument>, FacetQueryParameter <TDocument> >()
            .AddTransient <IFacetRangeParameter <TDocument>, FacetRangeParameter <TDocument> >()
            .AddTransient <IFacetSpatialParameter <TDocument>, FacetSpatialParameter <TDocument> >()
            .AddTransient <IFacetsResult <TDocument>, FacetsResult <TDocument> >()
            .AddTransient <IFieldsParameter <TDocument>, FieldsParameter <TDocument> >()
            .AddTransient <IFilterParameter <TDocument>, FilterParameter <TDocument> >()
            .AddTransient <IInformationResult <TDocument>, InformationResult <TDocument> >()
            .AddTransient <ILimitParameter <TDocument>, LimitParameter <TDocument> >()
            .AddTransient <ILocalParameter <TDocument>, LocalParameter <TDocument> >()
            .AddTransient <IFilterQueryParameter <TDocument>, FilterQueryParameter <TDocument> >()
            .AddTransient <IMinimumShouldMatchParameter <TDocument>, MinimumShouldMatchParameter <TDocument> >()
            .AddTransient <IOffsetParameter <TDocument>, OffsetParameter <TDocument> >()
            .AddTransient <IQueryFieldParameter <TDocument>, QueryFieldParameter <TDocument> >()
            .AddTransient <IQueryParameter <TDocument>, QueryParameter <TDocument> >()
            .AddTransient <IQueryParserParameter <TDocument>, QueryParserParameter <TDocument> >()
            .AddTransient <ISearchItemCollection <TDocument>, SearchItemCollection <TDocument> >()
            .AddTransient <ISortParameter <TDocument>, SortParameter <TDocument> >()
            .AddTransient <ISortRandomlyParameter <TDocument>, SortRandomlyParameter <TDocument> >()
            .AddTransient <ISpatialFilterParameter <TDocument>, SpatialFilterParameter <TDocument> >()
            .AddTransient <IStandardQueryParameter <TDocument>, StandardQueryParameter <TDocument> >()
            .AddTransient <ISystemParameter <TDocument>, SystemParameter <TDocument> >()
            .AddTransient <IWriteTypeParameter <TDocument>, WriteTypeParameter <TDocument> >();

            return(solrExpressBuilder);
        }
예제 #7
0
        /// <summary>
        /// Create a not mapped parameter
        /// </summary>
        /// <param name="solrExpressBuilder">Solr express builder</param>
        /// <param name="fieldExpression">Expression used to find field name</param>
        /// <param name="prefixName">Indicates prefix name in dynamic field configurations</param>
        /// <param name="suffixName">Indicates suffix name in dynamic field configurations</param>
        /// <returns>Solr express builder</returns>
        public static SolrExpressBuilder <TDocument> ChangeDynamicFieldBehaviour <TDocument>(this SolrExpressBuilder <TDocument> solrExpressBuilder, Expression <Func <TDocument, object> > fieldExpression, string prefixName = null, string suffixName = null)
            where TDocument : Document
        {
            Checker.IsNull(fieldExpression);

            var behaviour = solrExpressBuilder.ServiceProvider.GetService <IChangeDynamicFieldBehaviour <TDocument> >();

            behaviour.FieldExpression    = fieldExpression;
            behaviour.DynamicFieldPrefix = prefixName;
            behaviour.DynamicFieldSuffix = suffixName;

            solrExpressBuilder.Options.GlobalChangeBehaviours.Add(behaviour);

            return(solrExpressBuilder);
        }