/// <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); }
//============================================================ // PUBLIC METHODS //============================================================ #region Load(XPathNavigator source, XmlNamespaceManager manager) /// <summary> /// Initializes the syndication extension context using the supplied <see cref="XPathNavigator"/>. /// </summary> /// <param name="source">The <b>XPathNavigator</b> used to load this <see cref="YahooMediaSyndicationExtensionContext"/>.</param> /// <param name="manager">The <see cref="XmlNamespaceManager"/> object used to resolve prefixed syndication extension elements and attributes.</param> /// <returns><b>true</b> if the <see cref="YahooMediaSyndicationExtensionContext"/> was able to be initialized using the supplied <paramref name="source"/>; otherwise <b>false</b>.</returns> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception> public bool Load(XPathNavigator source, XmlNamespaceManager manager) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ bool wasLoaded = false; //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(source, "source"); Guard.ArgumentNotNull(manager, "manager"); //------------------------------------------------------------ // Attempt to extract syndication extension information //------------------------------------------------------------ if (source.HasChildren) { XPathNodeIterator contentIterator = source.Select("media:content", manager); XPathNodeIterator groupIterator = source.Select("media:group", manager); if (contentIterator != null && contentIterator.Count > 0) { while (contentIterator.MoveNext()) { YahooMediaContent content = new YahooMediaContent(); if (content.Load(contentIterator.Current)) { this.AddContent(content); wasLoaded = true; } } } if (groupIterator != null && groupIterator.Count > 0) { while (groupIterator.MoveNext()) { YahooMediaGroup group = new YahooMediaGroup(); if (group.Load(groupIterator.Current)) { this.AddGroup(group); wasLoaded = true; } } } } if (YahooMediaUtility.FillCommonObjectEntities(this, source)) { wasLoaded = true; } return(wasLoaded); }
//============================================================ // 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); }
/// <summary> /// Initializes the syndication extension context using the supplied <see cref="XPathNavigator"/>. /// </summary> /// <param name="source">The <b>XPathNavigator</b> used to load this <see cref="YahooMediaSyndicationExtensionContext"/>.</param> /// <param name="manager">The <see cref="XmlNamespaceManager"/> object used to resolve prefixed syndication extension elements and attributes.</param> /// <returns><b>true</b> if the <see cref="YahooMediaSyndicationExtensionContext"/> was able to be initialized using the supplied <paramref name="source"/>; otherwise <b>false</b>.</returns> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception> public bool Load(XPathNavigator source, XmlNamespaceManager manager) { bool wasLoaded = false; Guard.ArgumentNotNull(source, "source"); Guard.ArgumentNotNull(manager, "manager"); if (source.HasChildren) { XPathNodeIterator contentIterator = source.Select("media:content", manager); XPathNodeIterator groupIterator = source.Select("media:group", manager); if (contentIterator != null && contentIterator.Count > 0) { while (contentIterator.MoveNext()) { YahooMediaContent content = new YahooMediaContent(); if (content.Load(contentIterator.Current)) { this.AddContent(content); wasLoaded = true; } } } if (groupIterator != null && groupIterator.Count > 0) { while (groupIterator.MoveNext()) { YahooMediaGroup group = new YahooMediaGroup(); if (group.Load(groupIterator.Current)) { this.AddGroup(group); wasLoaded = true; } } } } if (YahooMediaUtility.FillCommonObjectEntities(this, source)) { wasLoaded = true; } return(wasLoaded); }
/// <summary> /// Loads 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> public bool Load(XPathNavigator source) { bool wasLoaded = false; Guard.ArgumentNotNull(source, "source"); wasLoaded = this.LoadPrimary(source); if (this.LoadSecondary(source)) { wasLoaded = true; } if (YahooMediaUtility.FillCommonObjectEntities(this, source)) { wasLoaded = true; } return(wasLoaded); }