/// <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) /// <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> /// 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); }
/// <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; }
/// <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; }