Esempio n. 1
0
        /// <summary>
        /// Parses the <paramref name="search"/> clause, binding
        /// the text into a metadata-bound list of properties to be selected using the provided model.
        /// </summary>
        /// <param name="search">String representation of the search expression from the URI.</param>
        /// <param name="configuration">The configuration used for binding.</param>
        /// <returns>A <see cref="SearchClause"/> representing the metadata bound search expression.</returns>
        private static SearchClause ParseSearchImplementation(string search, ODataUriParserConfiguration configuration)
        {
            ExceptionUtils.CheckArgumentNotNull(configuration, "configuration");
            ExceptionUtils.CheckArgumentNotNull(search, "search");

            SearchParser searchParser = new SearchParser(configuration.Settings.SearchLimit);
            QueryToken   queryToken   = searchParser.ParseSearch(search);

            // Bind it to metadata
            BindingState   state        = new BindingState(configuration);
            MetadataBinder binder       = new MetadataBinder(state);
            SearchBinder   searchBinder = new SearchBinder(binder.Bind);

            return(searchBinder.BindSearch(queryToken));
        }
Esempio n. 2
0
    IEnumerator DoSearch(string url, bool append = false)
    {
        ResultsDisplay.Instance.DisplayLoadingBar(append);
        using (UnityWebRequest request = UnityWebRequest.Get(url))
        {
            List <ProgramEntry> entries = new List <ProgramEntry>();
            request.SendWebRequest();

            while (!request.isDone)
            {
                _progress = request.downloadProgress;
                yield return(new WaitForEndOfFrame());
            }

            _progress = 1f;

            // Start reading the results

            if (request.isNetworkError || request.responseCode != 200)
            {
                Debug.Log("An error occurred: " + request.error);
                Debug.Log(request.downloadHandler.text);

                ResultsDisplay.Instance.DisplayError(string.Format("Response code {0}\nSomething went wrong! {1}\nResponse contents: {2}", request.responseCode, request.error, request.downloadHandler.text));
            }
            else
            {
                entries = SearchParser.ParseSearch(request.downloadHandler.text);

                // Check if our search resulted in no results
                if (entries.Count == 0)
                {
                    ResultsDisplay.Instance.DisplayError("No search results for '" + _lastSearch + "' :(");
                }
                else
                {
                    if (entries.Count < _limit)
                    {
                        EndOfResults = true;
                    }
                    ResultsDisplay.Instance.DisplayResults(entries, append);
                }
            }
        }
        SearchInProgress = false;
    }
Esempio n. 3
0
        public void SearchWordTest()
        {
            QueryToken token = searchParser.ParseSearch("zlexico");

            token.ShouldBeStringLiteralToken("zlexico");
        }