/// <summary>
        /// Saves the current <see cref="YahooMediaRestriction"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        public void WriteTo(XmlWriter writer)
        {
            Guard.ArgumentNotNull(writer, "writer");
            YahooMediaSyndicationExtension extension = new YahooMediaSyndicationExtension();

            writer.WriteStartElement("restriction", extension.XmlNamespace);

            if (this.Relationship != YahooMediaRestrictionRelationship.None)
            {
                writer.WriteAttributeString("relationship", YahooMediaRestriction.RelationshipAsString(this.Relationship));
            }

            if (this.EntityType != YahooMediaRestrictionType.None)
            {
                writer.WriteAttributeString("type", YahooMediaRestriction.RestrictionTypeAsString(this.EntityType));
            }

            if (this.Entities.Count > 0)
            {
                string[] entities = new string[this.Entities.Count];
                this.Entities.CopyTo(entities, 0);

                writer.WriteString(String.Join(" ", entities));
            }

            writer.WriteEndElement();
        }
Example #2
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaRestriction"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        public void WriteTo(XmlWriter writer)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(writer, "writer");

            //------------------------------------------------------------
            //	Create extension instance to retrieve XML namespace
            //------------------------------------------------------------
            YahooMediaSyndicationExtension extension = new YahooMediaSyndicationExtension();

            //------------------------------------------------------------
            //	Write XML representation of the current instance
            //------------------------------------------------------------
            writer.WriteStartElement("restriction", extension.XmlNamespace);

            if (this.Relationship != YahooMediaRestrictionRelationship.None)
            {
                writer.WriteAttributeString("relationship", YahooMediaRestriction.RelationshipAsString(this.Relationship));
            }

            if (this.EntityType != YahooMediaRestrictionType.None)
            {
                writer.WriteAttributeString("type", YahooMediaRestriction.RestrictionTypeAsString(this.EntityType));
            }

            if (this.Entities.Count > 0)
            {
                string[] entities = new string[this.Entities.Count];
                this.Entities.CopyTo(entities, 0);

                writer.WriteString(String.Join(" ", entities));
            }

            writer.WriteEndElement();
        }