Ejemplo n.º 1
0
        public async Task LoadAsync(MemoryStream stream)
        {
            XmlReader reader = XmlReader.Create(stream);

            try
            {
                bool foundPodcastNode = false;
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("Podcast", StringComparison.CurrentCultureIgnoreCase))
                    {
                        foundPodcastNode = true;
                    }
                    else if (foundPodcastNode && reader.NodeType == XmlNodeType.Element && reader.Name.Equals("FeedUri", StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (reader.Read() && reader.NodeType == XmlNodeType.Text)
                        {
                            string uri     = reader.Value;
                            var    podcast = await Podcast.GetPodcastAsync(uri);

                            Subscriptions.AddPodcast(podcast);
                        }
                    }
                    else if (foundPodcastNode && reader.NodeType == XmlNodeType.EndElement && reader.Name.Equals("Podcast", StringComparison.CurrentCultureIgnoreCase))
                    {
                        foundPodcastNode = false;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                reader.Dispose();
            }
        }