Пример #1
0
        /// <summary>
        /// Gets the story details.
        /// </summary>
        /// <param name="stories">The stories.</param>
        /// <returns>List&lt;Publication&gt;.</returns>
        private List <Publication> GetStoryDetails(List <Publication> stories)
        {
            if (skipDetails)
            {
                return(stories);
            }

            Parallel.ForEach(stories.OrderBy(o => int.Parse(o.publishedOn)), story =>
            {
                try
                {
                    using (WebClient cli = new WebClient())
                        story.UrlData = cli.DownloadString(story.Url);

                    OnNewsDetail(this, NewsDetailEventArgs.Create(story, watch));
                }
                catch (Exception)
                {
                    //TODO: need to log errors
                    return;
                }
            });

            OnNewsDetailComplete(this, NewsCompleteEventArgs.Create(stories, watch));
            return(stories);
        }
Пример #2
0
 /// <summary>
 /// Handles the <see cref="E:NewsEvent" /> event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="NewsSummaryEventArgs" /> instance containing the event data.</param>
 protected virtual void OnNewsDetail(object sender, NewsDetailEventArgs e)
 {
     NewsDetail?.Invoke(sender, e);
 }