/// <summary>
        /// Updates the specified media folder.
        /// </summary>
        /// <param name="force">If set to <c>true</c> [force] update.</param>
        internal void Update(bool force)
        {
            if (!this.Dynamic)
            {
                return;
            }

            if (force || ((DateTime.UtcNow - this.LastLoad).TotalSeconds > 300))
            {
                try
                {
                    this.Items.Clear();

                    switch (this.Title)
                    {
                    case "New Today":
                        this.RssSelector = new NewTodayRssSelector();
                        break;

                    default:
                        this.RssSelector = new RssSelector();
                        break;
                    }

                    this.RssLoader = new RssLoader();

                    ////if (sourceUrl.StartsWith("http://channel9.msdn.com/", true, CultureInfo.InvariantCulture))
                    ////{
                    this.RssParser = new Channel9RssParser();
                    ////}
                    ////else
                    ////{
                    ////    this.RssParser = new BasicRssParser();
                    ////}

                    XmlDocument      doc   = RssLoader.Load(this.SourceUrl);
                    XmlNodeList      nodes = this.RssSelector.Select(doc);
                    List <MediaItem> items = this.RssParser.Parse(nodes);

                    foreach (MediaItem item in items)
                    {
                        this.AddItem(item);
                    }

                    this.LastLoad = DateTime.UtcNow;
                }
                catch (Exception ex)
                {
                    Owner.Provider.LogMessage("Error: " + ex.Message);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Updates the specified media folder.
        /// </summary>
        /// <param name="force">If set to <c>true</c> [force] update.</param>
        internal void Update(bool force)
        {
            if (!this.Dynamic)
            {
                return;
            }

            if (!force && ((DateTime.UtcNow - this.LastLoad).TotalSeconds <= 300))
            {
                return;
            }

            try
            {
                this.Items.Clear();
                switch (this.Title)
                {
                case @"New Today":
                    this.RssSelector = new NewTodayRssSelector();
                    break;

                default:
                    this.RssSelector = new RssSelector();
                    break;
                }

                this.RssLoader = new RssLoader();
                this.RssParser = new Channel9RssParser();

                var nodes = this.RssSelector.Select(RssLoader.Load(this.SourceUrl));
                var items = this.RssParser.Parse(nodes);

                foreach (var item in items)
                {
                    this.AddItem(item);
                }

                this.LastLoad = DateTime.UtcNow;
            }
            catch (Exception ex)
            {
                Owner.Provider.LogMessage(Resources.ErrorLabel + ex.Message);
            }
        }