Exemplo n.º 1
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaHash"/> 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("hash", extension.XmlNamespace);

            if (this.Algorithm != YahooMediaHashAlgorithm.None)
            {
                writer.WriteAttributeString("algo", YahooMediaHash.HashAlgorithmAsString(this.Algorithm));
            }

            if (!String.IsNullOrEmpty(this.Value))
            {
                writer.WriteString(this.Value);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Saves the current <see cref="YahooMediaTextConstruct"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param>
        /// <param name="elementName">The local name of the text construct being written.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        public void WriteTo(XmlWriter writer, string elementName)
        {
            //------------------------------------------------------------
            //	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(elementName, extension.XmlNamespace);

            if (this.TextType != YahooMediaTextConstructType.None)
            {
                writer.WriteAttributeString("type", YahooMediaTextConstruct.TextTypeAsString(this.TextType));
            }

            if (!String.IsNullOrEmpty(this.Content))
            {
                writer.WriteString(this.Content);
            }

            writer.WriteEndElement();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads this <see cref="YahooMediaGroup"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaGroup"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="YahooMediaGroup"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(source, "source");
            YahooMediaSyndicationExtension extension = new YahooMediaSyndicationExtension();
            XmlNamespaceManager            manager   = extension.CreateNamespaceManager(source);

            if (source.HasChildren)
            {
                XPathNodeIterator contentIterator = source.Select("media:content", manager);

                if (contentIterator != null && contentIterator.Count > 0)
                {
                    while (contentIterator.MoveNext())
                    {
                        YahooMediaContent content = new YahooMediaContent();
                        if (content.Load(contentIterator.Current))
                        {
                            this.Contents.Add(content);
                            wasLoaded = true;
                        }
                    }
                }
            }

            if (YahooMediaUtility.FillCommonObjectEntities(this, source))
            {
                wasLoaded = true;
            }

            return(wasLoaded);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaPlayer"/> 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("player", extension.XmlNamespace);

            writer.WriteAttributeString("url", this.Url != null ? this.Url.ToString() : String.Empty);

            if (this.Height != Int32.MinValue)
            {
                writer.WriteAttributeString("height", this.Height.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Width != Int32.MinValue)
            {
                writer.WriteAttributeString("width", this.Width.ToString(NumberFormatInfo.InvariantInfo));
            }

            writer.WriteEndElement();
        }
        //============================================================
        //	ICOMPARABLE IMPLEMENTATION
        //============================================================
        #region CompareTo(object obj)
        /// <summary>
        /// Compares the current instance with another object of the same type.
        /// </summary>
        /// <param name="obj">An object to compare with this instance.</param>
        /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
        /// <exception cref="ArgumentException">The <paramref name="obj"/> is not the expected <see cref="Type"/>.</exception>
        public int CompareTo(object obj)
        {
            //------------------------------------------------------------
            //	If target is a null reference, instance is greater
            //------------------------------------------------------------
            if (obj == null)
            {
                return(1);
            }

            //------------------------------------------------------------
            //	Determine comparison result using property state of objects
            //------------------------------------------------------------
            YahooMediaSyndicationExtension value = obj as YahooMediaSyndicationExtension;

            if (value != null)
            {
                int result = YahooMediaUtility.CompareSequence((Collection <YahooMediaContent>) this.Context.Contents, (Collection <YahooMediaContent>)value.Context.Contents);
                result = result | YahooMediaUtility.CompareSequence((Collection <YahooMediaGroup>) this.Context.Groups, (Collection <YahooMediaGroup>)value.Context.Groups);

                result = result | YahooMediaUtility.CompareCommonObjectEntities(this.Context, value.Context);

                return(result);
            }
            else
            {
                throw new ArgumentException(String.Format(null, "obj is not of type {0}, type was found to be '{1}'.", this.GetType().FullName, obj.GetType().FullName), "obj");
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaGroup"/> 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("group", extension.XmlNamespace);

            foreach (YahooMediaContent content in this.Contents)
            {
                content.WriteTo(writer);
            }

            YahooMediaUtility.WriteCommonObjectEntities(this, writer);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Saves the current <see cref="YahooMediaThumbnail"/> 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("thumbnail", extension.XmlNamespace);

            writer.WriteAttributeString("url", this.Url != null ? this.Url.ToString() : String.Empty);

            if (this.Height != Int32.MinValue)
            {
                writer.WriteAttributeString("height", this.Height.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Width != Int32.MinValue)
            {
                writer.WriteAttributeString("width", this.Width.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Time != TimeSpan.MinValue)
            {
                writer.WriteAttributeString("time", this.Time.ToString());
            }

            writer.WriteEndElement();
        }
        private RssItem GetItem(string filePath)
        {
            var file = new FileInfo(filePath);

            if (!file.Exists)
                return null;

            string mimeType = GetMimeType(file);

            string fileName = Path.GetFileNameWithoutExtension(filePath);
            var uri = new Uri(GetUrl(Port, file.Name));

            var item = new RssItem();
            item.Title = fileName;
            item.Link = uri;

            item.Enclosures.Add(new RssEnclosure(file.Length, mimeType, item.Link));

            var extension = new YahooMediaSyndicationExtension();
            var mediaContent = new YahooMediaContent(uri);
            mediaContent.FileSize = file.Length;
            mediaContent.ContentType = mimeType;

            extension.Context.AddContent(mediaContent);
            item.AddExtension(extension);

            return item;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaCopyright"/> 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("copyright", extension.XmlNamespace);

            if (this.Url != null)
            {
                writer.WriteAttributeString("url", this.Url.ToString());
            }

            if (!String.IsNullOrEmpty(this.Text))
            {
                writer.WriteString(this.Text);
            }

            writer.WriteEndElement();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaText"/> 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("text", extension.XmlNamespace);

            if (this.TextType != YahooMediaTextConstructType.None)
            {
                writer.WriteAttributeString("type", YahooMediaText.TextTypeAsString(this.TextType));
            }

            if (this.Language != null)
            {
                writer.WriteAttributeString("lang", this.Language.Name);
            }

            if (this.Start != TimeSpan.MinValue)
            {
                writer.WriteAttributeString("start", this.Start.ToString());
            }

            if (this.End != TimeSpan.MinValue)
            {
                writer.WriteAttributeString("end", this.End.ToString());
            }

            if (!String.IsNullOrEmpty(this.Content))
            {
                writer.WriteString(this.Content);
            }

            writer.WriteEndElement();
        }
        /// <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();
        }
Exemplo n.º 12
0
        public string Generate(string title, List<string> filePaths, string imagePath = null)
        {
            // todo: add validation library - CuttingEdge.Conditions ?

            var feed = new RssFeed();
            feed.Channel.Link = new Uri(GetUrl(Port, "feed.xml"));
            feed.Channel.Title = title;

            if (imagePath != null)
            {
                var file = new FileInfo(imagePath);
                if (file.Exists)
                {
                    var extension = new YahooMediaSyndicationExtension();
                    extension.Context.Thumbnails.Add(new YahooMediaThumbnail(new Uri(GetUrl(Port, file.Name))));

                    feed.Channel.AddExtension(extension);
                }
            }

            foreach (string filePath in filePaths)
            {
                var item = GetItem(filePath);

                if (item != null)
                    feed.Channel.AddItem(item);
            }

            return feed.CreateNavigator().OuterXml;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaGroup"/> 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("group", extension.XmlNamespace);

            foreach (YahooMediaContent content in this.Contents)
            {
                content.WriteTo(writer);
            }

            YahooMediaUtility.WriteCommonObjectEntities(this, writer);

            writer.WriteEndElement();
        }
Exemplo n.º 14
0
        //============================================================
        //	PUBLIC METHODS
        //============================================================
        #region Load(XPathNavigator source)
        /// <summary>
        /// Loads this <see cref="YahooMediaGroup"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaGroup"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="YahooMediaGroup"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Initialize XML namespace resolver
            //------------------------------------------------------------
            YahooMediaSyndicationExtension extension = new YahooMediaSyndicationExtension();
            XmlNamespaceManager            manager   = extension.CreateNamespaceManager(source);

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if (source.HasChildren)
            {
                XPathNodeIterator contentIterator = source.Select("media:content", manager);

                if (contentIterator != null && contentIterator.Count > 0)
                {
                    while (contentIterator.MoveNext())
                    {
                        YahooMediaContent content = new YahooMediaContent();
                        if (content.Load(contentIterator.Current))
                        {
                            this.Contents.Add(content);
                            wasLoaded = true;
                        }
                    }
                }
            }

            if (YahooMediaUtility.FillCommonObjectEntities(this, source))
            {
                wasLoaded = true;
            }

            return(wasLoaded);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaText"/> 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("text", extension.XmlNamespace);

            if (this.TextType != YahooMediaTextConstructType.None)
            {
                writer.WriteAttributeString("type", YahooMediaText.TextTypeAsString(this.TextType));
            }

            if (this.Language != null)
            {
                writer.WriteAttributeString("lang", this.Language.Name);
            }

            if (this.Start != TimeSpan.MinValue)
            {
                writer.WriteAttributeString("start", this.Start.ToString());
            }

            if (this.End != TimeSpan.MinValue)
            {
                writer.WriteAttributeString("end", this.End.ToString());
            }

            if (!String.IsNullOrEmpty(this.Content))
            {
                writer.WriteString(this.Content);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Saves the current <see cref="YahooMediaTextConstruct"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param>
        /// <param name="elementName">The local name of the text construct being written.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        public void WriteTo(XmlWriter writer, string elementName)
        {
            Guard.ArgumentNotNull(writer, "writer");
            YahooMediaSyndicationExtension extension = new YahooMediaSyndicationExtension();

            writer.WriteStartElement(elementName, extension.XmlNamespace);

            if (this.TextType != YahooMediaTextConstructType.None)
            {
                writer.WriteAttributeString("type", YahooMediaTextConstruct.TextTypeAsString(this.TextType));
            }

            if (!String.IsNullOrEmpty(this.Content))
            {
                writer.WriteString(this.Content);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Saves the current <see cref="YahooMediaHash"/> 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("hash", extension.XmlNamespace);

            if (this.Algorithm != YahooMediaHashAlgorithm.None)
            {
                writer.WriteAttributeString("algo", YahooMediaHash.HashAlgorithmAsString(this.Algorithm));
            }

            if (!String.IsNullOrEmpty(this.Value))
            {
                writer.WriteString(this.Value);
            }

            writer.WriteEndElement();
        }
Exemplo n.º 18
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaCopyright"/> 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("copyright", extension.XmlNamespace);

            if (this.Url != null)
            {
                writer.WriteAttributeString("url", this.Url.ToString());
            }

            if (!String.IsNullOrEmpty(this.Text))
            {
                writer.WriteString(this.Text);
            }

            writer.WriteEndElement();
        }
Exemplo n.º 19
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaRating"/> 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("rating", extension.XmlNamespace);

            if (this.Scheme != null)
            {
                writer.WriteAttributeString("scheme", this.Scheme.ToString());
            }

            if (!String.IsNullOrEmpty(this.Content))
            {
                writer.WriteString(this.Content);
            }

            writer.WriteEndElement();
        }
Exemplo n.º 20
0
        /// <summary>
        /// Compares the current instance with another object of the same type.
        /// </summary>
        /// <param name="obj">An object to compare with this instance.</param>
        /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
        /// <exception cref="ArgumentException">The <paramref name="obj"/> is not the expected <see cref="Type"/>.</exception>
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            YahooMediaSyndicationExtension value = obj as YahooMediaSyndicationExtension;

            if (value != null)
            {
                int result = YahooMediaUtility.CompareSequence((Collection <YahooMediaContent>) this.Context.Contents, (Collection <YahooMediaContent>)value.Context.Contents);
                result = result | YahooMediaUtility.CompareSequence((Collection <YahooMediaGroup>) this.Context.Groups, (Collection <YahooMediaGroup>)value.Context.Groups);

                result = result | YahooMediaUtility.CompareCommonObjectEntities(this.Context, value.Context);

                return(result);
            }
            else
            {
                throw new ArgumentException(String.Format(null, "obj is not of type {0}, type was found to be '{1}'.", this.GetType().FullName, obj.GetType().FullName), "obj");
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Modifies the <see cref="IYahooMediaCommonObjectEntities"/> to match the data source.
        /// </summary>
        /// <param name="target">The object that implements the <see cref="IYahooMediaCommonObjectEntities"/> interface to be filled.</param>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract Yahoo media common entity information from.</param>
        /// <returns><b>true</b> if the <paramref name="target"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="target"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public static bool FillCommonObjectEntities(IYahooMediaCommonObjectEntities target, XPathNavigator source)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(target, "target");
            Guard.ArgumentNotNull(source, "source");
            YahooMediaSyndicationExtension extension = new YahooMediaSyndicationExtension();
            XmlNamespaceManager            manager   = extension.CreateNamespaceManager(source);

            wasLoaded = YahooMediaUtility.FillCommonObjectEntityClasses(target, source, manager);

            if (YahooMediaUtility.FillCommonObjectEntityCollectionsPrimary(target, source, manager))
            {
                wasLoaded = true;
            }

            if (YahooMediaUtility.FillCommonObjectEntityCollectionsSecondary(target, source, manager))
            {
                wasLoaded = true;
            }

            return(wasLoaded);
        }
Exemplo n.º 22
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();
        }
Exemplo n.º 23
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaTextConstruct"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param>
        /// <param name="elementName">The local name of the text construct being written.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        public void WriteTo(XmlWriter writer, string elementName)
        {
            //------------------------------------------------------------
            //	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(elementName, extension.XmlNamespace);

            if(this.TextType != YahooMediaTextConstructType.None)
            {
                writer.WriteAttributeString("type", YahooMediaTextConstruct.TextTypeAsString(this.TextType));
            }

            if(!String.IsNullOrEmpty(this.Content))
            {
                writer.WriteString(this.Content);
            }

            writer.WriteEndElement();
        }
Exemplo n.º 24
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaGroup"/> 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("group", extension.XmlNamespace);

            foreach (YahooMediaContent content in this.Contents)
            {
                content.WriteTo(writer);
            }

            YahooMediaUtility.WriteCommonObjectEntities(this, writer);

            writer.WriteEndElement();
        }
Exemplo n.º 25
0
        /// <summary>
        /// Loads this <see cref="YahooMediaGroup"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaGroup"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="YahooMediaGroup"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded              = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Initialize XML namespace resolver
            //------------------------------------------------------------
            YahooMediaSyndicationExtension extension    = new YahooMediaSyndicationExtension();
            XmlNamespaceManager manager                 = extension.CreateNamespaceManager(source);

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if(source.HasChildren)
            {
                XPathNodeIterator contentIterator   = source.Select("media:content", manager);

                if (contentIterator != null && contentIterator.Count > 0)
                {
                    while (contentIterator.MoveNext())
                    {
                        YahooMediaContent content   = new YahooMediaContent();
                        if (content.Load(contentIterator.Current))
                        {
                            this.Contents.Add(content);
                            wasLoaded   = true;
                        }
                    }
                }
            }

            if (YahooMediaUtility.FillCommonObjectEntities(this, source))
            {
                wasLoaded   = true;
            }

            return wasLoaded;
        }
Exemplo n.º 26
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaContent"/> 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("content", extension.XmlNamespace);

            if(this.Url != null)
            {
                writer.WriteAttributeString("url", this.Url.ToString());
            }

            if (this.FileSize != Int64.MinValue)
            {
                writer.WriteAttributeString("fileSize", this.FileSize.ToString(NumberFormatInfo.InvariantInfo));
            }

            if(!String.IsNullOrEmpty(this.ContentType))
            {
                writer.WriteAttributeString("type", this.ContentType);
            }

            if (this.Medium != YahooMediaMedium.None)
            {
                writer.WriteAttributeString("medium", YahooMediaSyndicationExtension.MediumAsString(this.Medium));
            }

            if(this.IsDefault)
            {
                writer.WriteAttributeString("isDefault", "true");
            }

            if (this.Expression != YahooMediaExpression.None)
            {
                writer.WriteAttributeString("expression", YahooMediaSyndicationExtension.ExpressionAsString(this.Expression));
            }

            if (this.Bitrate != Int32.MinValue)
            {
                writer.WriteAttributeString("bitrate", this.Bitrate.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.FrameRate != Int32.MinValue)
            {
                writer.WriteAttributeString("framerate", this.FrameRate.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.SamplingRate != Decimal.MinValue)
            {
                writer.WriteAttributeString("samplingrate", this.SamplingRate.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Channels != Int32.MinValue)
            {
                writer.WriteAttributeString("channels", this.Channels.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Duration != TimeSpan.MinValue)
            {
                writer.WriteAttributeString("duration", this.Duration.TotalSeconds.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Height != Int32.MinValue)
            {
                writer.WriteAttributeString("height", this.Height.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Width != Int32.MinValue)
            {
                writer.WriteAttributeString("width", this.Width.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Language != null)
            {
                writer.WriteAttributeString("lang", this.Language.Name);
            }

            YahooMediaUtility.WriteCommonObjectEntities(this, writer);

            writer.WriteEndElement();
        }
Exemplo n.º 27
0
        /// <summary>
        /// Saves the current <see cref="IYahooMediaCommonObjectEntities"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="source">A object that implements the <see cref="IYahooMediaCommonObjectEntities"/> interface to extract Yahoo media common entity information from.</param>
        /// <param name="writer">The <see cref="XmlWriter"/> to which the <paramref name="source"/> information will be written.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        public static void WriteCommonObjectEntities(IYahooMediaCommonObjectEntities source, XmlWriter writer)
        {
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(writer, "writer");
            YahooMediaSyndicationExtension extension = new YahooMediaSyndicationExtension();

            if (source.Title != null)
            {
                source.Title.WriteTo(writer, "title");
            }

            if (source.Description != null)
            {
                source.Description.WriteTo(writer, "description");
            }

            if (source.Copyright != null)
            {
                source.Copyright.WriteTo(writer);
            }

            if (source.Player != null)
            {
                source.Player.WriteTo(writer);
            }

            if (source.Keywords.Count > 0)
            {
                string[] keywords = new string[source.Keywords.Count];
                source.Keywords.CopyTo(keywords, 0);

                writer.WriteElementString("keywords", extension.XmlNamespace, String.Join(",", keywords));
            }

            foreach (YahooMediaCategory category in source.Categories)
            {
                category.WriteTo(writer);
            }

            foreach (YahooMediaCredit credit in source.Credits)
            {
                credit.WriteTo(writer);
            }

            foreach (YahooMediaHash hash in source.Hashes)
            {
                hash.WriteTo(writer);
            }

            foreach (YahooMediaRating rating in source.Ratings)
            {
                rating.WriteTo(writer);
            }

            foreach (YahooMediaRestriction restriction in source.Restrictions)
            {
                restriction.WriteTo(writer);
            }

            foreach (YahooMediaText text in source.TextSeries)
            {
                text.WriteTo(writer);
            }

            foreach (YahooMediaThumbnail thumbnail in source.Thumbnails)
            {
                thumbnail.WriteTo(writer);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Modifies the <see cref="IYahooMediaCommonObjectEntities"/> to match the data source.
        /// </summary>
        /// <param name="target">The object that implements the <see cref="IYahooMediaCommonObjectEntities"/> interface to be filled.</param>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract Yahoo media common entity information from.</param>
        /// <returns><b>true</b> if the <paramref name="target"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="target"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public static bool FillCommonObjectEntities(IYahooMediaCommonObjectEntities target, XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded  = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(target, "target");
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Initialize XML namespace resolver
            //------------------------------------------------------------
            YahooMediaSyndicationExtension extension    = new YahooMediaSyndicationExtension();
            XmlNamespaceManager manager                 = extension.CreateNamespaceManager(source);

            //------------------------------------------------------------
            //	Attempt to extract common entity information
            //------------------------------------------------------------
            wasLoaded   = YahooMediaUtility.FillCommonObjectEntityClasses(target, source, manager);

            if (YahooMediaUtility.FillCommonObjectEntityCollectionsPrimary(target, source, manager))
            {
                wasLoaded   = true;
            }

            if (YahooMediaUtility.FillCommonObjectEntityCollectionsSecondary(target, source, manager))
            {
                wasLoaded   = true;
            }

            return wasLoaded;
        }
Exemplo n.º 29
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaText"/> 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("text", extension.XmlNamespace);

            if (this.TextType != YahooMediaTextConstructType.None)
            {
                writer.WriteAttributeString("type", YahooMediaText.TextTypeAsString(this.TextType));
            }

            if (this.Language != null)
            {
                writer.WriteAttributeString("lang", this.Language.Name);
            }

            if (this.Start != TimeSpan.MinValue)
            {
                writer.WriteAttributeString("start", this.Start.ToString());
            }

            if (this.End != TimeSpan.MinValue)
            {
                writer.WriteAttributeString("end", this.End.ToString());
            }

            if (!String.IsNullOrEmpty(this.Content))
            {
                writer.WriteString(this.Content);
            }

            writer.WriteEndElement();
        }
Exemplo n.º 30
0
        /// <summary>
        /// Loads the primary properties of this <see cref="YahooMediaContent"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaContent"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="YahooMediaContent"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        private bool LoadPrimary(XPathNavigator source)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(source, "source");
            if (source.HasAttributes)
            {
                string urlAttribute        = source.GetAttribute("url", String.Empty);
                string fileSizeAttribute   = source.GetAttribute("fileSize", String.Empty);
                string typeAttribute       = source.GetAttribute("type", String.Empty);
                string mediumAttribute     = source.GetAttribute("medium", String.Empty);
                string isDefaultAttribute  = source.GetAttribute("isDefault", String.Empty);
                string expressionAttribute = source.GetAttribute("expression", String.Empty);
                string bitrateAttribute    = source.GetAttribute("bitrate", String.Empty);

                if (!String.IsNullOrEmpty(urlAttribute))
                {
                    Uri url;
                    if (Uri.TryCreate(urlAttribute, UriKind.RelativeOrAbsolute, out url))
                    {
                        this.Url  = url;
                        wasLoaded = true;
                    }
                }

                if (!String.IsNullOrEmpty(fileSizeAttribute))
                {
                    long fileSize;
                    if (Int64.TryParse(fileSizeAttribute, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out fileSize))
                    {
                        this.FileSize = fileSize;
                        wasLoaded     = true;
                    }
                }

                if (!String.IsNullOrEmpty(typeAttribute))
                {
                    this.ContentType = typeAttribute;
                    wasLoaded        = true;
                }

                if (!String.IsNullOrEmpty(mediumAttribute))
                {
                    YahooMediaMedium medium = YahooMediaSyndicationExtension.MediumByName(mediumAttribute);
                    if (medium != YahooMediaMedium.None)
                    {
                        this.Medium = medium;
                        wasLoaded   = true;
                    }
                }

                if (!String.IsNullOrEmpty(isDefaultAttribute))
                {
                    if (String.Compare(isDefaultAttribute, "true", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        this.IsDefault = true;
                        wasLoaded      = true;
                    }
                    else if (String.Compare(isDefaultAttribute, "false", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        this.IsDefault = false;
                        wasLoaded      = true;
                    }
                }

                if (!String.IsNullOrEmpty(expressionAttribute))
                {
                    YahooMediaExpression expression = YahooMediaSyndicationExtension.ExpressionByName(expressionAttribute);
                    if (expression != YahooMediaExpression.None)
                    {
                        this.Expression = expression;
                        wasLoaded       = true;
                    }
                }

                if (!String.IsNullOrEmpty(bitrateAttribute))
                {
                    int bitrate;
                    if (Int32.TryParse(bitrateAttribute, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out bitrate))
                    {
                        this.Bitrate = bitrate;
                        wasLoaded    = true;
                    }
                }
            }

            return(wasLoaded);
        }
Exemplo n.º 31
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaContent"/> 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("content", extension.XmlNamespace);

            if (this.Url != null)
            {
                writer.WriteAttributeString("url", this.Url.ToString());
            }

            if (this.FileSize != Int64.MinValue)
            {
                writer.WriteAttributeString("fileSize", this.FileSize.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (!String.IsNullOrEmpty(this.ContentType))
            {
                writer.WriteAttributeString("type", this.ContentType);
            }

            if (this.Medium != YahooMediaMedium.None)
            {
                writer.WriteAttributeString("medium", YahooMediaSyndicationExtension.MediumAsString(this.Medium));
            }

            if (this.IsDefault)
            {
                writer.WriteAttributeString("isDefault", "true");
            }

            if (this.Expression != YahooMediaExpression.None)
            {
                writer.WriteAttributeString("expression", YahooMediaSyndicationExtension.ExpressionAsString(this.Expression));
            }

            if (this.Bitrate != Int32.MinValue)
            {
                writer.WriteAttributeString("bitrate", this.Bitrate.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.FrameRate != Int32.MinValue)
            {
                writer.WriteAttributeString("framerate", this.FrameRate.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.SamplingRate != Decimal.MinValue)
            {
                writer.WriteAttributeString("samplingrate", this.SamplingRate.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Channels != Int32.MinValue)
            {
                writer.WriteAttributeString("channels", this.Channels.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Duration != TimeSpan.MinValue)
            {
                writer.WriteAttributeString("duration", this.Duration.TotalSeconds.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Height != Int32.MinValue)
            {
                writer.WriteAttributeString("height", this.Height.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Width != Int32.MinValue)
            {
                writer.WriteAttributeString("width", this.Width.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Language != null)
            {
                writer.WriteAttributeString("lang", this.Language.Name);
            }

            YahooMediaUtility.WriteCommonObjectEntities(this, writer);

            writer.WriteEndElement();
        }
Exemplo n.º 32
0
        /// <summary>
        /// Saves the current <see cref="IYahooMediaCommonObjectEntities"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="source">A object that implements the <see cref="IYahooMediaCommonObjectEntities"/> interface to extract Yahoo media common entity information from.</param>
        /// <param name="writer">The <see cref="XmlWriter"/> to which the <paramref name="source"/> information will be written.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        public static void WriteCommonObjectEntities(IYahooMediaCommonObjectEntities source, XmlWriter writer)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(writer, "writer");

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

            //------------------------------------------------------------
            //	Write common entity information
            //------------------------------------------------------------
            if (source.Title != null)
            {
                source.Title.WriteTo(writer, "title");
            }

            if (source.Description != null)
            {
                source.Description.WriteTo(writer, "description");
            }

            if (source.Copyright != null)
            {
                source.Copyright.WriteTo(writer);
            }

            if (source.Player != null)
            {
                source.Player.WriteTo(writer);
            }

            if(source.Keywords.Count > 0)
            {
                string[] keywords = new string[source.Keywords.Count];
                source.Keywords.CopyTo(keywords, 0);

                writer.WriteElementString("keywords", extension.XmlNamespace, String.Join(",", keywords));
            }

            foreach(YahooMediaCategory category in source.Categories)
            {
                category.WriteTo(writer);
            }

            foreach (YahooMediaCredit credit in source.Credits)
            {
                credit.WriteTo(writer);
            }

            foreach (YahooMediaHash hash in source.Hashes)
            {
                hash.WriteTo(writer);
            }

            foreach (YahooMediaRating rating in source.Ratings)
            {
                rating.WriteTo(writer);
            }

            foreach (YahooMediaRestriction restriction in source.Restrictions)
            {
                restriction.WriteTo(writer);
            }

            foreach (YahooMediaText text in source.TextSeries)
            {
                text.WriteTo(writer);
            }

            foreach (YahooMediaThumbnail thumbnail in source.Thumbnails)
            {
                thumbnail.WriteTo(writer);
            }
        }
Exemplo n.º 33
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaThumbnail"/> 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("thumbnail", extension.XmlNamespace);

            writer.WriteAttributeString("url", this.Url != null ? this.Url.ToString() : String.Empty);

            if(this.Height != Int32.MinValue)
            {
                writer.WriteAttributeString("height", this.Height.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Width != Int32.MinValue)
            {
                writer.WriteAttributeString("width", this.Width.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (this.Time != TimeSpan.MinValue)
            {
                writer.WriteAttributeString("time", this.Time.ToString());
            }

            writer.WriteEndElement();
        }
Exemplo n.º 34
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaRating"/> 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("rating", extension.XmlNamespace);

            if(this.Scheme != null)
            {
                writer.WriteAttributeString("scheme", this.Scheme.ToString());
            }

            if(!String.IsNullOrEmpty(this.Content))
            {
                writer.WriteString(this.Content);
            }

            writer.WriteEndElement();
        }
Exemplo n.º 35
0
        /// <summary>
        /// Saves the current <see cref="YahooMediaHash"/> 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("hash", extension.XmlNamespace);

            if(this.Algorithm != YahooMediaHashAlgorithm.None)
            {
                writer.WriteAttributeString("algo", YahooMediaHash.HashAlgorithmAsString(this.Algorithm));
            }

            if(!String.IsNullOrEmpty(this.Value))
            {
                writer.WriteString(this.Value);
            }

            writer.WriteEndElement();
        }
Exemplo n.º 36
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();
        }