Exemplo n.º 1
0
        public void Execute(IList <IFilter> filters, PipelineSettings pipelineSettings)
        {
            IEnumerable <SyndicationItem> items;

            if (pipelineSettings.Inputs != null)
            {
                // Get a list of feed items
                items = from feed in ParallelCrawl(pipelineSettings.Inputs)
                        from i in feed.Items
                        select i;
            }
            else
            {
                items = new SyndicationItem[0];
            }

            // Filter
            IEnumerable <SyndicationItem> filtered = items
                                                     .Where(x => ApplyFilters(filters, x) == FilterAction.Include);

            // Remove duplicates
            IEnumerable <SyndicationItem> merged = Deduplicate(filtered);

            if (pipelineSettings.Output != null)
            {
                // Save results
                var newFeed = new SyndicationFeed(merged.OrderBy(i => i.PublishDate));

                newFeed.Title           = SyndicationContent.CreatePlaintextContent(pipelineSettings.Title);
                newFeed.Description     = SyndicationContent.CreatePlaintextContent(pipelineSettings.Description);
                newFeed.LastUpdatedTime = DateTimeOffset.Now;

                using (XmlWriter writer = XmlWriter.Create(pipelineSettings.Output))
                {
                    newFeed.SaveAsAtom10(writer);
                }
            }
        }
        public void Execute(IList<IFilter> filters, PipelineSettings pipelineSettings)
        {
            IEnumerable<SyndicationItem> items;

            if (pipelineSettings.Inputs != null)
            {
                // Get a list of feed items
                items = from feed in ParallelCrawl(pipelineSettings.Inputs)
                                                        from i in feed.Items
                                                        select i;
            }
            else
            {
                items = new SyndicationItem[0];
            }

            // Filter
            IEnumerable<SyndicationItem> filtered = items
                .Where(x => ApplyFilters(filters, x) == FilterAction.Include);

            // Remove duplicates
            IEnumerable<SyndicationItem> merged = Dedup(filtered);

            if (pipelineSettings.Output != null)
            {
                // Save results
                var newFeed = new SyndicationFeed(merged.OrderBy(i => i.PublishDate));

                newFeed.Title = SyndicationContent.CreatePlaintextContent(pipelineSettings.Title);
                newFeed.Description = SyndicationContent.CreatePlaintextContent(pipelineSettings.Description);
                newFeed.LastUpdatedTime = DateTimeOffset.Now;

                using (XmlWriter writer = XmlWriter.Create(pipelineSettings.Output))
                {
                    newFeed.SaveAsAtom10(writer);
                }
            }
        }