Esempio n. 1
0
        private static void ParseProperty(string[] nameVal, SearchQueryModel model)
        {
            if (nameVal.Length < 2)
            {
                return;
            }
            var key = nameVal[0];

            if (model.FilterBy.ContainsKey(key))
            {
                return;
            }
            model.FilterBy.Add(key, nameVal[1]);
        }
Esempio n. 2
0
        private static void ParseOrdering(string queryVal, SearchQueryModel model)
        {
            var lexems = queryVal.Split('-');

            for (int i = 0; i < lexems.Length / 2; i += 2)
            {
                if (lexems.Length >= i + 1)
                {
                    continue;
                }
                string propName = lexems[i], dir = lexems[i + 1];
                model.OrderBy.Add(propName, dir);
            }
        }
Esempio n. 3
0
        protected static SearchQueryModel ParseQuery(string query)
        {
            var res    = new SearchQueryModel();
            var lexems = query.Split('&')
                         .Select(lx => lx.Split('='))
                         .Where(lexem => lexem.Length > 1);

            foreach (var nameVal in lexems)
            {
                queryLexems.Push(nameVal);
                string key = nameVal[0].ToLower();

                if (parseInstructions.ContainsKey(key))
                {
                    parseInstructions[key](nameVal[1], res);
                }
                else
                {
                    ParseProperty(nameVal, res);
                }
            }
            queryLexems.Clear();
            return(res);
        }
Esempio n. 4
0
 private static void SetApplyTrue(string key, SearchQueryModel model)
 {
     model.Apply = true;
 }
Esempio n. 5
0
 private static void SetPageNum(string queryVal, SearchQueryModel model)
 {
     uint.TryParse(queryVal, out uint page);
     model.Page = page;
 }