Beispiel #1
0
        public void WriteXml(XmlWriter writer)
        {
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

            ns.Add("", "");

            writer.WriteElementString("episodeType", Namespaces.ITunes, EpisodeType.ToString());

            if (Episode.HasValue)
            {
                writer.WriteElementString("episode", Namespaces.ITunes, Episode.Value.ToString());
            }

            if (Season.HasValue)
            {
                writer.WriteElementString("season", Namespaces.ITunes, Season.Value.ToString());
            }

            writer.WriteElementString("title", Title);

            if (!string.IsNullOrWhiteSpace(Subtitle))
            {
                writer.WriteElementString("subtitle", Namespaces.ITunes, Subtitle);
            }

            /*
             * These nodes will be populated with the Description property
             */
            writer.WriteElementString("description", Description);
            writer.WriteElementString("summary", Namespaces.ITunes, Description);

            if (!string.IsNullOrWhiteSpace(DescriptionEncoded))
            {
                writer.WriteStartElement("encoded", Namespaces.Content);
                writer.WriteCData(DescriptionEncoded);
                writer.WriteEndElement();
            }

            writer.WriteElementString("author", Namespaces.ITunes, Author);

            XmlSerializerNamespaces ns2 = new XmlSerializerNamespaces();

            ns2.Add("itunes", Namespaces.ITunes);
            new XmlSerializer(typeof(Image)).Serialize(writer, Image, ns2);

            writer.WriteElementString("link", Link);
            new XmlSerializer(typeof(Enclosure)).Serialize(writer, Enclosure, ns);
            writer.WriteElementString("guid", Guid);
            writer.WriteElementString("pubDate", PubDate.ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss +0000"));
            writer.WriteElementString("duration", Namespaces.ITunes, Duration.ToString());
            writer.WriteElementString("explicit", Namespaces.ITunes, Explicit ? "true" : "false");
        }