Esempio n. 1
0
        public override Query GetQuery()
        {
            if (string.IsNullOrWhiteSpace(_queryString))
            {
                return(new EmptyQuery());
            }

            var parser      = new MultiFieldQueryParser(QueryUtils.GetQueryStrings(typeof(T)), _analyzer);
            var queryString = QueryParser.Escape(_queryString);

            return(parser.Parse(queryString));
        }
Esempio n. 2
0
        protected virtual List <T> HitsToContract <T>(SearchResult hits) where T : class, new()
        {
            var result       = new List <T>();
            var queryStrings = QueryUtils.GetQueryStrings(typeof(T));

            for (int i = 0; i < hits.TotalHits; i++)
            {
                Assembly assembly = Assembly.GetAssembly(typeof(T));
                T        obj      = assembly.CreateInstance(String.Join(".", new[] { typeof(T).Namespace, typeof(T).Name })) as T;
                foreach (PropertyInfo property in obj.GetType().GetProperties())
                {
                    if (queryStrings.Contains(property.Name) && property.CanWrite)
                    {
                        obj.SetValue(property, hits.Docs[i].Get(property.Name));
                    }
                }
                result.Add(obj);
            }

            return(result);
        }
Esempio n. 3
0
        public void should_get_queryStrings()
        {
            var queryStrings = QueryUtils.GetQueryStrings(typeof(SpaceObject));

            Assert.IsTrue(queryStrings.Contains("Name"));
        }