/// <summary> /// Initializes SolrNet with the built-in container /// </summary> /// <typeparam name="T"></typeparam> /// <param name="connection"></param> public static void Init <T>(ISolrConnection connection) { var connectionKey = string.Format("{0}.{1}.{2}", typeof(SolrConnection), typeof(T), connection.GetType()); Container.Register(connectionKey, c => connection); var activator = new SolrDocumentActivator <T>(); Container.Register <ISolrDocumentActivator <T> >(c => activator); Container.Register(ChooseDocumentResponseParser <T>); Container.Register <ISolrAbstractResponseParser <T> >(typeof(ResultsResponseParser <T>).FullName, c => new ResultsResponseParser <T>(c.GetInstance <ISolrDocumentResponseParser <T> >())); Container.Register <ISolrAbstractResponseParser <T> >(typeof(HeaderResponseParser <T>).FullName, c => new HeaderResponseParser <T>()); Container.Register <ISolrAbstractResponseParser <T> >(typeof(FacetsResponseParser <T>).FullName, c => new FacetsResponseParser <T>()); Container.Register <ISolrAbstractResponseParser <T> >(typeof(InterestingTermsResponseParser <T>).FullName, c => new InterestingTermsResponseParser <T>()); Container.Register <ISolrAbstractResponseParser <T> >(typeof(MoreLikeThisHandlerMatchResponseParser <T>).FullName, c => new MoreLikeThisHandlerMatchResponseParser <T>(c.GetInstance <ISolrDocumentResponseParser <T> >())); Container.Register <ISolrResponseParser <T> >(typeof(HighlightingResponseParser <T>).FullName, c => new HighlightingResponseParser <T>()); Container.Register <ISolrResponseParser <T> >(typeof(MoreLikeThisResponseParser <T>).FullName, c => new MoreLikeThisResponseParser <T>(c.GetInstance <ISolrDocumentResponseParser <T> >())); Container.Register <ISolrResponseParser <T> >(typeof(SpellCheckResponseParser <T>).FullName, c => new SpellCheckResponseParser <T>()); Container.Register <ISolrResponseParser <T> >(typeof(TermsResponseParser <T>).FullName, c => new TermsResponseParser <T>()); Container.Register <ISolrResponseParser <T> >(typeof(StatsResponseParser <T>).FullName, c => new StatsResponseParser <T>()); Container.Register <ISolrResponseParser <T> >(typeof(CollapseResponseParser <T>).FullName, c => new CollapseResponseParser <T>()); Container.Register <ISolrResponseParser <T> >(typeof(ClusterResponseParser <T>).FullName, c => new ClusterResponseParser <T>()); Container.Register <ISolrResponseParser <T> >(typeof(GroupingResponseParser <T>).FullName, c => new GroupingResponseParser <T>(c.GetInstance <ISolrDocumentResponseParser <T> >())); Container.Register <ISolrQueryResultParser <T> >(c => new SolrQueryResultParser <T>(c.GetAllInstances <ISolrAbstractResponseParser <T> >().ToArray())); Container.Register <ISolrMoreLikeThisHandlerQueryResultsParser <T> >(c => new SolrMoreLikeThisHandlerQueryResultsParser <T>(c.GetAllInstances <ISolrAbstractResponseParser <T> >().ToArray())); Container.Register <ISolrQueryExecuter <T> >(c => new SolrQueryExecuter <T>(c.GetInstance <ISolrQueryResultParser <T> >(), connection, c.GetInstance <ISolrQuerySerializer>(), c.GetInstance <ISolrFacetQuerySerializer>(), c.GetInstance <ISolrMoreLikeThisHandlerQueryResultsParser <T> >())); Container.Register(ChooseDocumentSerializer <T>); Container.Register <ISolrBasicOperations <T> >(c => new SolrBasicServer <T>(connection, c.GetInstance <ISolrQueryExecuter <T> >(), c.GetInstance <ISolrDocumentSerializer <T> >(), c.GetInstance <ISolrSchemaParser>(), c.GetInstance <ISolrHeaderResponseParser>(), c.GetInstance <ISolrQuerySerializer>(), c.GetInstance <ISolrDIHStatusParser>(), c.GetInstance <ISolrExtractResponseParser>())); Container.Register <ISolrBasicReadOnlyOperations <T> >(c => new SolrBasicServer <T>(connection, c.GetInstance <ISolrQueryExecuter <T> >(), c.GetInstance <ISolrDocumentSerializer <T> >(), c.GetInstance <ISolrSchemaParser>(), c.GetInstance <ISolrHeaderResponseParser>(), c.GetInstance <ISolrQuerySerializer>(), c.GetInstance <ISolrDIHStatusParser>(), c.GetInstance <ISolrExtractResponseParser>())); Container.Register <ISolrOperations <T> >(c => new SolrServer <T>(c.GetInstance <ISolrBasicOperations <T> >(), Container.GetInstance <IReadOnlyMappingManager>(), Container.GetInstance <IMappingValidator>())); Container.Register <ISolrReadOnlyOperations <T> >(c => new SolrServer <T>(c.GetInstance <ISolrBasicOperations <T> >(), Container.GetInstance <IReadOnlyMappingManager>(), Container.GetInstance <IMappingValidator>())); }
/// <summary> /// Initializes SolrNet with the built-in container /// </summary> /// <typeparam name="T"></typeparam> /// <param name="connection"></param> public static void Init <T>(ISolrConnection connection) { var connectionKey = string.Format("{0}.{1}.{2}", typeof(SolrConnection), typeof(T), connection.GetType()); Container.Register(connectionKey, c => connection); var activator = new SolrDocumentActivator <T>(); Container.Register <ISolrDocumentActivator <T> >(c => activator); Container.Register(ChooseDocumentResponseParser <T>); Container.Register <ISolrAbstractResponseParser <T> >(c => new DefaultResponseParser <T>(c.GetInstance <ISolrDocumentResponseParser <T> >())); Container.Register <ISolrMoreLikeThisHandlerQueryResultsParser <T> >(c => new SolrMoreLikeThisHandlerQueryResultsParser <T>(c.GetAllInstances <ISolrAbstractResponseParser <T> >().ToArray())); Container.Register <ISolrQueryExecuter <T> >(c => new SolrQueryExecuter <T>(c.GetInstance <ISolrAbstractResponseParser <T> >(), connection, c.GetInstance <ISolrQuerySerializer>(), c.GetInstance <ISolrFacetQuerySerializer>(), c.GetInstance <ISolrMoreLikeThisHandlerQueryResultsParser <T> >())); Container.Register(ChooseDocumentSerializer <T>); Container.Register <ISolrBasicOperations <T> >(c => new SolrBasicServer <T>(connection, c.GetInstance <ISolrQueryExecuter <T> >(), c.GetInstance <ISolrDocumentSerializer <T> >(), c.GetInstance <ISolrSchemaParser>(), c.GetInstance <ISolrHeaderResponseParser>(), c.GetInstance <ISolrQuerySerializer>(), c.GetInstance <ISolrDIHStatusParser>(), c.GetInstance <ISolrExtractResponseParser>())); Container.Register <ISolrBasicReadOnlyOperations <T> >(c => new SolrBasicServer <T>(connection, c.GetInstance <ISolrQueryExecuter <T> >(), c.GetInstance <ISolrDocumentSerializer <T> >(), c.GetInstance <ISolrSchemaParser>(), c.GetInstance <ISolrHeaderResponseParser>(), c.GetInstance <ISolrQuerySerializer>(), c.GetInstance <ISolrDIHStatusParser>(), c.GetInstance <ISolrExtractResponseParser>())); Container.Register <ISolrOperations <T> >(c => new SolrServer <T>(c.GetInstance <ISolrBasicOperations <T> >(), Container.GetInstance <IReadOnlyMappingManager>(), Container.GetInstance <IMappingValidator>())); Container.Register <ISolrReadOnlyOperations <T> >(c => new SolrServer <T>(c.GetInstance <ISolrBasicOperations <T> >(), Container.GetInstance <IReadOnlyMappingManager>(), Container.GetInstance <IMappingValidator>())); var coreAdminKey = typeof(ISolrCoreAdmin).Name + connectionKey; Container.Register <ISolrCoreAdmin>(coreAdminKey, c => new SolrCoreAdmin(connection, c.GetInstance <ISolrHeaderResponseParser>(), c.GetInstance <ISolrStatusResponseParser>())); }
/// <summary> /// Initializes SolrNet with the built-in container /// </summary> /// <typeparam name="T"></typeparam> /// <param name="connection"></param> public static void Init <T>(ISolrConnection connection) { var connectionKey = string.Format("{0}.{1}.{2}", typeof(SolrConnection), typeof(T), connection.GetType()); Container.Register(connectionKey, c => connection); var activator = new SolrDocumentActivator <T>(); Container.Register <ISolrDocumentActivator <T> >(c => activator); Container.Register <ISolrQueryExecuter <T> >(c => new SolrQueryExecuter <T>(connection, c.GetInstance <ISolrQuerySerializer>(), c.GetInstance <ISolrFacetQuerySerializer>())); Container.Register <ISolrBasicOperations <T> >(c => new SolrBasicServer <T>(connection, c.GetInstance <ISolrQueryExecuter <T> >(), c.GetInstance <ISolrQuerySerializer>())); //todo Container.Register <ISolrBasicReadOnlyOperations <T> >(c => new SolrBasicServer <T>(connection, c.GetInstance <ISolrQueryExecuter <T> >(), c.GetInstance <ISolrQuerySerializer>())); //todo Container.Register <ISolrOperations <T> >(c => new SolrServer <T>(c.GetInstance <ISolrBasicOperations <T> >(), Container.GetInstance <IReadOnlyMappingManager>())); Container.Register <ISolrReadOnlyOperations <T> >(c => new SolrServer <T>(c.GetInstance <ISolrBasicOperations <T> >(), Container.GetInstance <IReadOnlyMappingManager>())); }