コード例 #1
0
        public void SearchForSubject()
        {
            string subject = "Religion och kultur";

            // GIVEN a format of json (default)
            // AND GIVEN a limit on the number of search result items to three (default)
            xSearchRestClient = new XSearchRestClient("http://libris.kb.se/xsearch");

            // WHEN the search by subject is executed and the response recieved
            string jsonResponseString = xSearchRestClient.ExecuteXSearchRequest(subject);
            Console.WriteLine(jsonResponseString);

            // THEN the number of returned search result items should be three
            XSearchResults results = new XSearchResults(jsonResponseString);
            Assert.AreEqual(3, results.SearchResultItems.Count);
        }
コード例 #2
0
        private void performXSearchProcessing(IEnumerable<String> subjectsToSearch)
        {
            Parallel.ForEach(subjectsToSearch, (subject) =>
            {
                try
                {
                    XSearchRestClient xSearchRestClient = new XSearchRestClient(ConfigurationManager.AppSettings["XsearchBaseUrl"]);
                    string jsonResponseString = xSearchRestClient.ExecuteXSearchRequest(subject);
                    XSearchResults currentResults = new XSearchResults(jsonResponseString);
                    currentResults.PrettyPrintResultsToConsole(subject);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(String.Format("Unexpected error occured when performing Xsearch expansion for subject {0}: {1}",
                        subject,
                        ex.Message));
                }

            });
        }