當前位置: 首頁>>代碼示例>>C#>>正文


C# Impl.SolrConnection類代碼示例

本文整理匯總了C#中SolrNet.Impl.SolrConnection的典型用法代碼示例。如果您正苦於以下問題:C# SolrConnection類的具體用法?C# SolrConnection怎麽用?C# SolrConnection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SolrConnection類屬於SolrNet.Impl命名空間,在下文中一共展示了SolrConnection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SetupSolr

        private static void SetupSolr() {
            var connection = new SolrConnection(_httpSolrTest);
            Startup.InitContainer();

            Startup.Container.Remove<IReadOnlyMappingManager>();

            var mapper = new MappingManager();
            Mappings(mapper);
            Startup.Container.Register<IReadOnlyMappingManager>(c => mapper);

            Startup.Container.Remove<ISolrDocumentPropertyVisitor>();
            var propertyVisitor = new DefaultDocumentVisitor(mapper, Startup.Container.GetInstance<ISolrFieldParser>());
            Startup.Container.Register<ISolrDocumentPropertyVisitor>(c => propertyVisitor);

            Startup.Init<Child>(connection);
            Startup.Init<Parent>(connection);
            Startup.Init<Dictionary<string,object>>(connection);
            Startup.Container.RemoveAll<ISolrDocumentResponseParser<Dictionary<string, object>>>();
            Startup.Container.Register<ISolrDocumentResponseParser<Dictionary<string, object>>>(c => new SolrDictionaryDocumentResponseParser(c.GetInstance<ISolrFieldParser>()));

            var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Child>>();

            solr.Delete(SolrQuery.All);
            solr.Commit();
        }
開發者ID:FilipVV,項目名稱:SolrNet,代碼行數:25,代碼來源:IntegrationTests2.cs

示例2: Main

 static void Main(string[] args)
 {
     var builder = Startup.GetQueryBuilder();
     var conn = new SolrConnection("http://localhost:9090/solr");
     var query = builder.GetQuery(conn, new SolrQuery("*:*"), new QueryOptions {Rows = 99});
     Console.WriteLine(query);
     Console.ReadLine();
 }
開發者ID:Jroland,項目名稱:SolrNet,代碼行數:8,代碼來源:Program.cs

示例3: ActualConnection

        public void ActualConnection() {
            var conn = new SolrConnection(solrURL) { HttpWebRequestFactory = new HttpWebRequestFactory() };
            var p = new Dictionary<string, string>();
            p["version"] = "2.1";
            p["indent"] = "on";
            p["q"] = "+video +price:[* TO 400]";
            Console.WriteLine(conn.Get("/select/", p));
        }
開發者ID:FilipVV,項目名稱:SolrNet,代碼行數:8,代碼來源:SolrConnectionTests.cs

示例4: ActualInvalidFieldException

 public void ActualInvalidFieldException()
 {
     var conn = new SolrConnection(solrURL, new HttpWebRequestFactory());
     var p = new Dictionary<string, string>();
     p["version"] = "2.1";
     p["indent"] = "on";
     p["q"] = "idq:123";
     Console.WriteLine(conn.Get("/select/", p));
 }
開發者ID:rupertbates,項目名稱:SolrNet,代碼行數:9,代碼來源:SolrConnectionTests.cs

示例5: Cache

 public void Cache()
 {
     var conn = new SolrConnection(solrURL);
     conn.Get("/select/", new Dictionary<string, string> {
         {"q", "*:*"},
     });
     conn.Get("/select/", new Dictionary<string, string> {
         {"q", "*:*"},
     });
 }
開發者ID:jokin,項目名稱:SolrNet,代碼行數:10,代碼來源:SolrConnectionTests.cs

示例6: Cache

 public void Cache()
 {
     var conn = new SolrConnection(solrURL, new HttpWebRequestFactory());
     var response1 = conn.Get("/select/", new Dictionary<string, string> {
         {"q", "*:*"},
     });
     var response2 = conn.Get("/select/", new Dictionary<string, string> {
         {"q", "*:*"},
     });
 }
開發者ID:rupertbates,項目名稱:SolrNet,代碼行數:10,代碼來源:SolrConnectionTests.cs

示例7: Application_Start

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var solrServerUrl = ConfigurationManager.AppSettings["SolrServerUrl"];
            var solrConnection = new SolrConnection(solrServerUrl);
            Startup.Init<SearchResultItem>(solrConnection);
        }
開發者ID:jstrassburg,項目名稱:SolrSearchEngineDemo,代碼行數:13,代碼來源:Global.asax.cs

示例8: ActualConnectionWithException

        public void ActualConnectionWithException() {
            var conn = new SolrConnection(solrURL);
            var p = new Dictionary<string, string>();
            p["version"] = "2.1";
            p["indent"] = "on";
            p["q"] = "idq:123";
            try {
                conn.Get("/select/", p);
                Assert.Fail("Should have thrown");
            } catch (SolrConnectionException e) {
                Console.WriteLine(e);
                Console.WriteLine(e.Url);
            }
        }
開發者ID:FilipVV,項目名稱:SolrNet,代碼行數:14,代碼來源:SolrConnectionTests.cs

示例9: Application_Start

        protected void Application_Start() {
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(Server.MapPath("/"), "log4net.config")));

            RegisterRoutes(RouteTable.Routes);

            var connection = new SolrConnection(solrURL);
            var loggingConnection = new LoggingConnection(connection);
            Startup.Init<Product>(loggingConnection);

            RegisterAllControllers();
            ControllerBuilder.Current.SetControllerFactory(new ServiceProviderControllerFactory(Startup.Container));
            ModelBinders.Binders[typeof (SearchParameters)] = new SearchParametersBinder();
            AddInitialDocuments();
        }
開發者ID:simendancer,項目名稱:SolrNet,代碼行數:14,代碼來源:Global.asax.cs

示例10: Get

        public void Get() {
            var response = new Mocks.HttpWebResponse {
                dispose = () => {},
                headers = () => new WebHeaderCollection(),
                getResponseStream = () => new MemoryStream(Encoding.UTF8.GetBytes("hello world")),
            };
            var request = new Mocks.HttpWebRequest {
                getResponse = () => response
            };
            var reqFactory = new Mocks.HttpWebRequestFactory {
                create = _ => request
            };
            var conn = new SolrConnection("https://pepe") {
                HttpWebRequestFactory = reqFactory,
            };
            var r = conn.Get("", new Dictionary<string, string>());
            Assert.AreEqual("hello world", r);
        }
開發者ID:FilipVV,項目名稱:SolrNet,代碼行數:18,代碼來源:SolrConnectionTests.cs

示例11: Post

 public void Post()
 {
     var mocks = new MockRepository();
     var reqFactory = mocks.StrictMock<IHttpWebRequestFactory>();
     var request = mocks.DynamicMock<IHttpWebRequest>();
     var response = mocks.DynamicMock<IHttpWebResponse>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(request.GetRequestStream())
             .Repeat.Once()
             .Return(new MemoryStream());
         Expect.Call(reqFactory.Create(new Uri("https://pepe")))
             .Repeat.Once()
             .Return(request);
         request.Method = HttpWebRequestMethod.POST;
         LastCall.On(request).Repeat.Once();
         Expect.Call(request.GetResponse())
             .Repeat.Once()
             .Return(response);
         Expect.Call(response.Headers)
             .Repeat.Any()
             .Return(new WebHeaderCollection());
         Expect.Call(response.GetResponseStream())
             .Repeat.Once()
             .Return(new MemoryStream());
     }).Verify(delegate {
         var conn = new SolrConnection("https://pepe", reqFactory);
         conn.Post("", "");
     });
 }
開發者ID:rupertbates,項目名稱:SolrNet,代碼行數:29,代碼來源:SolrConnectionTests.cs

示例12: NoCache_performance

 public void NoCache_performance()
 {
     var conn = new SolrConnection(solrURL, new HttpWebRequestFactory()) {
         Cache = new NullCache(),
     };
     TestCache(conn);
 }
開發者ID:rupertbates,項目名稱:SolrNet,代碼行數:7,代碼來源:SolrConnectionTests.cs

示例13: InvalidHostPost_ShouldThrowException

 public void InvalidHostPost_ShouldThrowException()
 {
     var mocks = new MockRepository();
     var reqFactory = mocks.StrictMock<IHttpWebRequestFactory>();
     var request = mocks.DynamicMock<IHttpWebRequest>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(request.GetRequestStream())
             .Repeat.Once()
             .Throw(new WebException());
         Expect.Call(reqFactory.Create(new Uri("http://lalala:12345/update")))
             .IgnoreArguments()
             .Repeat.Once()
             .Return(request);
     }).Verify(delegate {
         var conn = new SolrConnection("http://lalala:12345", reqFactory);
         conn.Post("/update", "");
     });
 }
開發者ID:rupertbates,項目名稱:SolrNet,代碼行數:18,代碼來源:SolrConnectionTests.cs

示例14: InvalidHostGet_ShouldThrowException

 public void InvalidHostGet_ShouldThrowException()
 {
     var mocks = new MockRepository();
     var reqFactory = mocks.StrictMock<IHttpWebRequestFactory>();
     var request = mocks.DynamicMock<IHttpWebRequest>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(reqFactory.Create(new UriBuilder().Uri))
             .IgnoreArguments()
             .Repeat.Once()
             .Return(request);
         Expect.Call(request.GetResponse())
             .Repeat.Once()
             .Throw(new WebException());
     }).Verify(delegate {
         var conn = new SolrConnection("http://lalala:12345", reqFactory);
         conn.Get("", new Dictionary<string, string>());
     });
 }
開發者ID:rupertbates,項目名稱:SolrNet,代碼行數:18,代碼來源:SolrConnectionTests.cs

示例15: GetWithNullParameters_ShouldAcceptNull

 public void GetWithNullParameters_ShouldAcceptNull()
 {
     var mocks = new MockRepository();
     var reqFactory = mocks.StrictMock<IHttpWebRequestFactory>();
     var request = mocks.DynamicMock<IHttpWebRequest>();
     var response = mocks.DynamicMock<IHttpWebResponse>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(reqFactory.Create(new UriBuilder().Uri))
             .IgnoreArguments()
             .Repeat.Once()
             .Return(request);
         Expect.Call(response.Headers)
             .Repeat.Any()
             .Return(new WebHeaderCollection());
         Expect.Call(request.GetResponse())
             .Repeat.Once()
             .Return(response);
         Expect.Call(response.GetResponseStream())
             .Repeat.Once()
             .Return(new MemoryStream());
     }).Verify(delegate {
         var conn = new SolrConnection("https://pepe", reqFactory);
         conn.Get("", new Dictionary<string, string>());
     });
 }
開發者ID:rupertbates,項目名稱:SolrNet,代碼行數:25,代碼來源:SolrConnectionTests.cs


注:本文中的SolrNet.Impl.SolrConnection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。