Exemplo n.º 1
0
        /// <summary>
        /// Creates an <see cref="XmlReader" /> for reading an Atom feed from
        /// the provided <see cref="Uri" />.
        /// </summary>
        /// <param name="href">
        /// The relative <see cref="Uri" /> of the Atom feed to read.
        /// </param>
        /// <returns>
        /// An <see cref="XmlReader" /> over the Atom feed identified by
        /// <paramref name="href" />.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="href" /> is <see langword="null" />.
        /// </exception>
        /// <remarks>
        /// <para>
        /// This method attempts to find a file corresponding to
        /// <paramref name="href" />. If the file is found, an
        /// <see cref="XmlReader" /> over that file is created and returned. If
        /// the file isn't found, an XmlReader over an empty Atom Feed is
        /// returned. In this case, no file is created for the empty Atom Feed.
        /// In other words: this method has no observable side-effects.
        /// </para>
        /// </remarks>
        public XmlReader CreateFeedReaderFor(Uri href)
        {
            if (href == null)
            {
                throw new ArgumentNullException("href");
            }

            var fileName = this.CreateFileName(href);

            if (File.Exists(fileName))
            {
                return(XmlReader.Create(fileName));
            }

            return(AtomEventStorage.CreateNewFeed(href));
        }
Exemplo n.º 2
0
        public XmlReader CreateFeedReaderFor(Uri href)
        {
            if (href == null)
            {
                throw new ArgumentNullException("href");
            }

            this.rwLock.EnterReadLock();
            try
            {
                if (this.feeds.ContainsKey(href))
                {
                    return(CreateReaderOver(this.feeds[href].ToString()));
                }
                else
                {
                    return(AtomEventStorage.CreateNewFeed(href));
                }
            }
            finally
            {
                this.rwLock.ExitReadLock();
            }
        }