Beispiel #1
0
        public static TimeSpan Measure(ISearchAlgorithm sortAlgorithm, IArrayGenerator arrayGenerator, int value)
        {
            var    array     = arrayGenerator.GetArray;
            Action act       = () => sortAlgorithm.Contains(array, value);
            var    stopwatch = new Stopwatch();

            stopwatch.Start();
            act.Invoke();
            stopwatch.Stop();
            return(stopwatch.Elapsed);
        }
        public Expression <Func <SearchHit <SearchResultItem>, bool> > Comparison(SearchSettings settings)
        {
            var query = settings.Queries.Where(x => x.Key == settings.TemplateID).FirstOrDefault().Value;

            settings.CompareFiledType = _sitecoreService.GetItemById(new GetItemByIdOptions {
                Id = Guid.Parse(settings.TemplateID)
            }).Name;
            var rootPredicates = PredicateBuilder.False <SearchHit <SearchResultItem> >();

            foreach (var oper in _operators)
            {
                if (_searchAlgorithm.Contains(query, oper.Identifier))
                {
                    rootPredicates = oper.BuildCondition(settings, rootPredicates);
                }
            }
            return(rootPredicates);
        }