/// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="xml">The XML.</param>
        /// <returns>OpmlDocument</returns>
        public static OpmlDocument Load(string xml)
        {
            if (String.IsNullOrEmpty(xml))
            {
                throw new ArgumentException(string.Format(Resources.RssToolkit.Culture, Resources.RssToolkit.ArgmentException, "xml"));
            }

            OpmlDocument doc = new OpmlDocument();

            using (StringReader stringReader = new StringReader(xml))
            {
                XmlSerializer x = new XmlSerializer(typeof(OpmlDocument));
                using (XmlTextReader xmlReader = new XmlTextReader(stringReader))
                {
                    doc = (OpmlDocument)x.Deserialize(xmlReader);
                }
            }

            return(doc);
        }
Example #2
0
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="xml">The XML.</param>
        /// <returns>OpmlDocument</returns>
        public static OpmlDocument Load(string xml)
        {
            if (String.IsNullOrEmpty(xml))
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The argument '{0}' is Null or Empty", "xml"));
            }

            OpmlDocument doc = new OpmlDocument();

            using (StringReader stringReader = new StringReader(xml))
            {
                XmlSerializer x = new XmlSerializer(typeof(OpmlDocument));
                using (XmlTextReader xmlReader = new XmlTextReader(stringReader))
                {
                    doc = (OpmlDocument)x.Deserialize(xmlReader);
                }
            }

            return(doc);
        }
        private void Load(OpmlDocument opmlDocument)
        {
            rssEvents = new AutoResetEvent[opmlDocument.Body.Outlines.Count];

            LoadRssFeeds(opmlDocument);

            MergeRss(opmlDocument.Head.Title);
        }
        private void LoadRssFeeds(OpmlDocument opmlDocument)
        {
            IList<OpmlOutline> outlines = opmlDocument.Body.Outlines;
            for (int index = 0; index < outlines.Count; index++)
            {
                if (rssEvents[index] == null)
                {
                    rssEvents[index] = new AutoResetEvent(false);
                }

                ThreadPool.QueueUserWorkItem(new WaitCallback(GetRssFeeds), new OutlineInfo(outlines[index], index));
            }

            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
            {
                // WaitAll for multiple handles on an STA thread is not supported. 
                // ...so wait on each handle individually. 
                foreach (WaitHandle waitHandle in rssEvents)
                {
                    WaitHandle.WaitAny(new WaitHandle[] { waitHandle });
                }
            }
            else
            {
                WaitHandle.WaitAll(rssEvents);
            }
        }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="xml">The XML.</param>
        /// <returns>OpmlDocument</returns>
        public static OpmlDocument Load(string xml)
        {
            if (String.IsNullOrEmpty(xml))
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The argument '{0}' is Null or Empty", "xml"));
            }

            OpmlDocument doc = new OpmlDocument();
            using (StringReader stringReader = new StringReader(xml))
            {
                XmlSerializer x = new XmlSerializer(typeof(OpmlDocument));
                using (XmlTextReader xmlReader = new XmlTextReader(stringReader))
                {
                    doc = (OpmlDocument)x.Deserialize(xmlReader);
                }
            }

            return doc;
        }
Example #6
0
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="xml">The XML.</param>
        /// <returns>OpmlDocument</returns>
        public static OpmlDocument Load(string xml)
        {
            if (String.IsNullOrEmpty(xml))
            {
                throw new ArgumentException(string.Format(Resources.RssToolkit.Culture, Resources.RssToolkit.ArgmentException, "xml"));
            }

            OpmlDocument doc = new OpmlDocument();
            using (StringReader stringReader = new StringReader(xml))
            {
                XmlSerializer x = new XmlSerializer(typeof(OpmlDocument));
                using (XmlTextReader xmlReader = new XmlTextReader(stringReader))
                {
                    doc = (OpmlDocument)x.Deserialize(xmlReader);
                }
            }

            return doc;
        }