Exemplo n.º 1
0
        public IReadOnlyDictionary <IItem, IItemFilterBlock> ProcessItemsAgainstItemFilterScript(IItemFilterScript itemFilterScript, IEnumerable <IItem> items)
        {
            var overallsw = Stopwatch.StartNew();

            var matchedItemBlockPairs = new Dictionary <IItem, IItemFilterBlock>();

            var sw = Stopwatch.StartNew();

            foreach (var item in items)
            {
                sw.Restart();

                var matchedBlock = itemFilterScript.ItemFilterBlocks
                                   .Where(b => !(b is ItemFilterSection))
                                   .FirstOrDefault(block => _blockItemMatcher.ItemBlockMatch(block, item));

                matchedItemBlockPairs.Add(item, matchedBlock);

                Debug.WriteLine("Processed Item in {0}ms", sw.ElapsedMilliseconds);
            }
            sw.Stop();

            overallsw.Stop();
            Debug.WriteLine("Total processing time: {0}ms", overallsw.ElapsedMilliseconds);
            return(matchedItemBlockPairs);
        }
Exemplo n.º 2
0
        public List <IFilteredItem> ProcessItemsAgainstItemFilterScript(IItemFilterScript itemFilterScript, IEnumerable <IItem> items)
        {
            var overallsw = Stopwatch.StartNew();

            var filteredItems = new List <IFilteredItem>();

            var sw = Stopwatch.StartNew();

            foreach (var item in items)
            {
                sw.Restart();

                var matchedBlock = itemFilterScript.ItemFilterBlocks
                                   .OfType <IItemFilterBlock>()
                                   .FirstOrDefault(block => _blockItemMatcher.ItemBlockMatch(block, item));

                filteredItems.Add(new FilteredItem(item, matchedBlock));

                Debug.WriteLine("Processed Item in {0}ms", sw.ElapsedMilliseconds);
            }
            sw.Stop();

            overallsw.Stop();
            Debug.WriteLine("Total processing time: {0}ms", overallsw.ElapsedMilliseconds);
            return(filteredItems);
        }