Example #1
0
        /// <summary>Writes the RSS feed to the specified stream.</summary>
        /// <param name="stream">specified Stream</param>
        /// <exception cref="ArgumentException">The Stream cannot be written to.</exception>
        /// <exception cref="InvalidOperationException">Feed must contain at least one channel.</exception>
        /// <exception cref="InvalidOperationException">Channel must contain at least one item.</exception>
        public void Write(Stream stream)
        {
            RssWriter writer;

            if (encoding == null)
            {
                writer = RssWriter.Create(stream, this.Version);
            }
            else
            {
                writer = RssWriter.Create(stream, this.Version, encoding);
            }
            write(writer);
        }
Example #2
0
        /// <summary>Writes the RSS feed to the specified stream.</summary>
        /// <param name="stream">specified Stream</param>
        /// <exception cref="ArgumentException">The Stream cannot be written to.</exception>
        /// <exception cref="InvalidOperationException">Feed must contain at least one channel.</exception>
        /// <exception cref="InvalidOperationException">Channel must contain at least one item.</exception>
        public void Write(Stream stream)
        {
            RssWriter writer;

            if (encoding == null)
            {
                writer = new RssWriter(stream);
            }
            else
            {
                writer = new RssWriter(stream, encoding);
            }
            write(writer);
        }
Example #3
0
        private static RssWriter Create(XmlTextWriter writer, RssVersion version)
        {
            RssWriter rssWriter = null;

            switch (version)
            {
            case RssVersion.RSS20:
                rssWriter = new Rss20Writer(writer);
                break;

            default:
                throw new NotSupportedException("The specified RSS version is not currently supported.");
            }
            return(rssWriter);
        }
Example #4
0
        /// <summary>Writes the RSS feed to the specified file.</summary>
        /// <remarks>The encoding is ISO-8859-1.</remarks>
        /// <exception cref="ArgumentException">The filename is empty, contains only white space, or contains one or more invalid characters.</exception>
        /// <exception cref="UnauthorizedAccessException">Access is denied.</exception>
        /// <exception cref="ArgumentNullException">The filename is a (null c#, Nothing vb) reference.</exception>
        /// <exception cref="DirectoryNotFoundException">The directory to write to is not found.</exception>
        /// <exception cref="IOException">The filename includes an incorrect or invalid syntax for file name, directory name, or volume label syntax.</exception>
        /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception>
        /// <param name="fileName">specified file (including path) If the file exists, it will be truncated with the new content.</param>
        /// <exception cref="InvalidOperationException">Feed must contain at least one channel.</exception>
        /// <exception cref="InvalidOperationException">Channel must contain at least one item.</exception>
        public void Write(string fileName)
        {
            RssWriter writer = new RssWriter(fileName);

            write(writer);
        }
Example #5
0
        private void write(RssWriter writer)
        {
            try
            {
                if (channels.Count == 0)
                    throw new InvalidOperationException("Feed must contain at least one channel.");

                writer.Version = rssVersion;

                writer.Modules = modules;

                foreach (RssChannel channel in channels)
                {
                    if (channel.Items.Count == 0)
                        throw new InvalidOperationException("Channel must contain at least one item.");

                    writer.Write(channel);
                }
            }
            finally
            {
                if (writer != null)
                    writer.Close();
            }
        }
Example #6
0
 /// <summary>Writes the RSS feed to the specified file.</summary>
 /// <remarks>The encoding is ISO-8859-1.</remarks>
 /// <exception cref="ArgumentException">The filename is empty, contains only white space, or contains one or more invalid characters.</exception>
 /// <exception cref="UnauthorizedAccessException">Access is denied.</exception>
 /// <exception cref="ArgumentNullException">The filename is a (null c#, Nothing vb) reference.</exception>
 /// <exception cref="DirectoryNotFoundException">The directory to write to is not found.</exception>
 /// <exception cref="IOException">The filename includes an incorrect or invalid syntax for file name, directory name, or volume label syntax.</exception>
 /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// <param name="fileName">specified file (including path) If the file exists, it will be truncated with the new content.</param>
 /// <exception cref="InvalidOperationException">Feed must contain at least one channel.</exception>
 /// <exception cref="InvalidOperationException">Channel must contain at least one item.</exception>
 public void Write(string fileName)
 {
     RssWriter writer = new RssWriter(fileName);
     write(writer);
 }
Example #7
0
        /// <summary>Writes the RSS feed to the specified stream.</summary>
        /// <param name="stream">specified Stream</param>
        /// <exception cref="ArgumentException">The Stream cannot be written to.</exception>
        /// <exception cref="InvalidOperationException">Feed must contain at least one channel.</exception>
        /// <exception cref="InvalidOperationException">Channel must contain at least one item.</exception>
        public void Write(Stream stream)
        {
            RssWriter writer;

            if (encoding == null)
                writer = new RssWriter(stream);
            else
                writer = new RssWriter(stream, encoding);
            write(writer);
        }
Example #8
0
 /// <summary>Creates an instance of the RssWriter class using the specified file.</summary>
 /// <remarks>The encoding is ISO-8859-1 and the version is RSS 2.0.</remarks>
 /// <exception cref="ArgumentException">The filename is empty, contains only white space, or contains one or more invalid characters.</exception>
 /// <exception cref="UnauthorizedAccessException">Access is denied.</exception>
 /// <exception cref="ArgumentNullException">The filename is a (null c#, Nothing vb) reference.</exception>
 /// <exception cref="DirectoryNotFoundException">The directory to write to is not found.</exception>
 /// <exception cref="IOException">The filename includes an incorrect or invalid syntax for file name, directory name, or volume label syntax.</exception>
 /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// <param name="fileName">specified file (including path) If the file exists, it will be truncated with the new content.</param>
 /// <returns>The new instance.</returns>
 public static RssWriter Create(string fileName)
 {
     return(RssWriter.Create(fileName, DefaultRssVersion, DefaultEncoding));
 }
Example #9
0
 /// <summary>Creates an instance of the RssWriter class using the specified file.</summary>
 /// <remarks>The encoding is ISO-8859-1 and the version is RSS 2.0.</remarks>
 /// <exception cref="ArgumentException">The filename is empty, contains only white space, or contains one or more invalid characters.</exception>
 /// <exception cref="UnauthorizedAccessException">Access is denied.</exception>
 /// <exception cref="ArgumentNullException">The filename is a (null c#, Nothing vb) reference.</exception>
 /// <exception cref="DirectoryNotFoundException">The directory to write to is not found.</exception>
 /// <exception cref="IOException">The filename includes an incorrect or invalid syntax for file name, directory name, or volume label syntax.</exception>
 /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// <param name="fileName">specified file (including path) If the file exists, it will be truncated with the new content.</param>
 /// <param name="version">the RSS version to output.</param>
 /// <returns>The new instance.</returns>
 public static RssWriter Create(string fileName, RssVersion version)
 {
     return(RssWriter.Create(new XmlTextWriter(fileName, DefaultEncoding), DefaultRssVersion));
 }
Example #10
0
 /// <summary>Creates an instance of the RssWriter class using the specified file and Encoding.</summary>
 /// <exception cref="ArgumentException">The encoding is not supported; the filename is empty, contains only white space, or contains one or more invalid characters.</exception>
 /// <exception cref="UnauthorizedAccessException">Access is denied.</exception>
 /// <exception cref="ArgumentNullException">The filename is a (null c#, Nothing vb) reference.</exception>
 /// <exception cref="DirectoryNotFoundException">The directory to write to is not found.</exception>
 /// <exception cref="IOException">The filename includes an incorrect or invalid syntax for file name, directory name, or volume label syntax.</exception>
 /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// <param name="fileName">specified file (including path) If the file exists, it will be truncated with the new content.</param>
 /// <param name="version">the RSS version for output.</param>
 /// <param name="encoding">specified Encoding</param>
 public static RssWriter Create(string fileName, RssVersion version, Encoding encoding)
 {
     return(RssWriter.Create(new XmlTextWriter(fileName, encoding), version));
 }
Example #11
0
 /// <summary>Creates an instance of the RssWriter class using the specified TextWriter.</summary>
 /// <param name="textWriter">specified TextWriter</param>
 /// <param name="version">The RSS version for output.</param>
 public static RssWriter Create(TextWriter textWriter, RssVersion version)
 {
     return(RssWriter.Create(new XmlTextWriter(textWriter), version));
 }
Example #12
0
 /// <summary>Creates an instance of the RssWriter class using the specified Stream and Encoding.</summary>
 /// <exception cref="ArgumentException">The encoding is not supported or the stream cannot be written to.</exception>
 /// <param name="stream">Stream to output to</param>
 /// <param name="version">The RSS version for output.</param>
 /// <param name="encoding">The encoding to use. If encoding is (null c#, Nothing vb) it writes out the stream as UTF-8.</param>
 /// <returns>The new instance.</returns>
 public static RssWriter Create(Stream stream, RssVersion version, Encoding encoding)
 {
     return(RssWriter.Create(new XmlTextWriter(stream, encoding), version));
 }
Example #13
0
 /// <summary>Creates an instance of the RssWriter class using the specified Stream, and encoded to ISO-8859-1.</summary>
 /// <param name="stream">Stream to output to</param>
 /// <param name="version">The RSS version for output.</param>
 /// <returns>The new instance.</returns>
 public static RssWriter Create(Stream stream, RssVersion version)
 {
     return(RssWriter.Create(stream, version, DefaultEncoding));
 }
Example #14
0
        /// <summary>Writes the RSS feed to the specified file.</summary>
        /// <remarks>The encoding is ISO-8859-1.</remarks>
        /// <exception cref="ArgumentException">The filename is empty, contains only white space, or contains one or more invalid characters.</exception>
        /// <exception cref="UnauthorizedAccessException">Access is denied.</exception>
        /// <exception cref="ArgumentNullException">The filename is a (null c#, Nothing vb) reference.</exception>
        /// <exception cref="DirectoryNotFoundException">The directory to write to is not found.</exception>
        /// <exception cref="IOException">The filename includes an incorrect or invalid syntax for file name, directory name, or volume label syntax.</exception>
        /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception>
        /// <param name="fileName">specified file (including path) If the file exists, it will be truncated with the new content.</param>
        /// <exception cref="InvalidOperationException">Feed must contain at least one channel.</exception>
        /// <exception cref="InvalidOperationException">Channel must contain at least one item.</exception>
        public void Write(string fileName)
        {
            RssWriter writer = RssWriter.Create(fileName, this.Version);

            write(writer);
        }