/// <summary> /// Modifies the primary collections of a <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> /// <param name="manager">The <see cref="XmlNamespaceManager"/> object used to resolve prefixed Yahoo media elements and attributes.</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> /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception> private static bool FillCommonObjectEntityCollectionsPrimary(IYahooMediaCommonObjectEntities target, XPathNavigator source, XmlNamespaceManager manager) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ bool wasLoaded = false; //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(target, "target"); Guard.ArgumentNotNull(source, "source"); Guard.ArgumentNotNull(manager, "manager"); //------------------------------------------------------------ // Attempt to extract common entity information //------------------------------------------------------------ if(source.HasChildren) { XPathNodeIterator categoryIterator = source.Select("media:category", manager); XPathNodeIterator creditIterator = source.Select("media:credit", manager); XPathNodeIterator ratingIterator = source.Select("media:rating", manager); XPathNodeIterator thumbnailIterator = source.Select("media:thumbnail", manager); if (categoryIterator != null && categoryIterator.Count > 0) { while (categoryIterator.MoveNext()) { YahooMediaCategory category = new YahooMediaCategory(); if (category.Load(categoryIterator.Current)) { target.Categories.Add(category); wasLoaded = true; } } } if (creditIterator != null && creditIterator.Count > 0) { while (creditIterator.MoveNext()) { YahooMediaCredit credit = new YahooMediaCredit(); if (credit.Load(creditIterator.Current)) { target.Credits.Add(credit); wasLoaded = true; } } } if (ratingIterator != null && ratingIterator.Count > 0) { while (ratingIterator.MoveNext()) { YahooMediaRating rating = new YahooMediaRating(); if (rating.Load(ratingIterator.Current)) { target.Ratings.Add(rating); wasLoaded = true; } } } if (thumbnailIterator != null && thumbnailIterator.Count > 0) { while (thumbnailIterator.MoveNext()) { YahooMediaThumbnail thumbnail = new YahooMediaThumbnail(); if (thumbnail.Load(thumbnailIterator.Current)) { target.Thumbnails.Add(thumbnail); wasLoaded = true; } } } } return wasLoaded; }
/// <summary> /// Modifies the primary collections of a <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> /// <param name="manager">The <see cref="XmlNamespaceManager"/> object used to resolve prefixed Yahoo media elements and attributes.</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> /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception> private static bool FillCommonObjectEntityCollectionsPrimary(IYahooMediaCommonObjectEntities target, XPathNavigator source, XmlNamespaceManager manager) { bool wasLoaded = false; Guard.ArgumentNotNull(target, "target"); Guard.ArgumentNotNull(source, "source"); Guard.ArgumentNotNull(manager, "manager"); if (source.HasChildren) { XPathNodeIterator categoryIterator = source.Select("media:category", manager); XPathNodeIterator creditIterator = source.Select("media:credit", manager); XPathNodeIterator ratingIterator = source.Select("media:rating", manager); XPathNodeIterator thumbnailIterator = source.Select("media:thumbnail", manager); if (categoryIterator != null && categoryIterator.Count > 0) { while (categoryIterator.MoveNext()) { YahooMediaCategory category = new YahooMediaCategory(); if (category.Load(categoryIterator.Current)) { target.Categories.Add(category); wasLoaded = true; } } } if (creditIterator != null && creditIterator.Count > 0) { while (creditIterator.MoveNext()) { YahooMediaCredit credit = new YahooMediaCredit(); if (credit.Load(creditIterator.Current)) { target.Credits.Add(credit); wasLoaded = true; } } } if (ratingIterator != null && ratingIterator.Count > 0) { while (ratingIterator.MoveNext()) { YahooMediaRating rating = new YahooMediaRating(); if (rating.Load(ratingIterator.Current)) { target.Ratings.Add(rating); wasLoaded = true; } } } if (thumbnailIterator != null && thumbnailIterator.Count > 0) { while (thumbnailIterator.MoveNext()) { YahooMediaThumbnail thumbnail = new YahooMediaThumbnail(); if (thumbnail.Load(thumbnailIterator.Current)) { target.Thumbnails.Add(thumbnail); wasLoaded = true; } } } } return(wasLoaded); }