//============================================================ // PUBLIC METHODS //============================================================ #region Load(XPathNavigator source) /// <summary> /// Loads this <see cref="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/>. /// </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"); //------------------------------------------------------------ // Create namespace manager to resolve prefixed elements //------------------------------------------------------------ SiteSummaryContentSyndicationExtension extension = new SiteSummaryContentSyndicationExtension(); XmlNamespaceManager manager = extension.CreateNamespaceManager(source); //------------------------------------------------------------ // Attempt to extract syndication information //------------------------------------------------------------ if (source.HasChildren) { XPathNavigator formatNavigator = source.SelectSingleNode("content:format", manager); XPathNavigator encodingNavigator = source.SelectSingleNode("content:encoding", manager); if (formatNavigator != null) { Uri format; if (Uri.TryCreate(formatNavigator.Value, UriKind.RelativeOrAbsolute, out format)) { this.Format = format; wasLoaded = true; } } if (encodingNavigator != null) { Uri encoding; if (Uri.TryCreate(encodingNavigator.Value, UriKind.RelativeOrAbsolute, out encoding)) { this.Encoding = encoding; wasLoaded = true; } } } if (!String.IsNullOrEmpty(source.Value)) { this.Content = source.Value; wasLoaded = true; } return(wasLoaded); }
/// <summary> /// Loads this <see cref="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/>. /// </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"); SiteSummaryContentSyndicationExtension extension = new SiteSummaryContentSyndicationExtension(); XmlNamespaceManager manager = extension.CreateNamespaceManager(source); if (source.HasChildren) { XPathNavigator formatNavigator = source.SelectSingleNode("content:format", manager); XPathNavigator encodingNavigator = source.SelectSingleNode("content:encoding", manager); if (formatNavigator != null) { Uri format; if (Uri.TryCreate(formatNavigator.Value, UriKind.RelativeOrAbsolute, out format)) { this.Format = format; wasLoaded = true; } } if (encodingNavigator != null) { Uri encoding; if (Uri.TryCreate(encodingNavigator.Value, UriKind.RelativeOrAbsolute, out encoding)) { this.Encoding = encoding; wasLoaded = true; } } } if (!String.IsNullOrEmpty(source.Value)) { this.Content = source.Value; wasLoaded = true; } return(wasLoaded); }
/// <summary> /// Loads this <see cref="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/>. /// </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"); //------------------------------------------------------------ // Create namespace manager to resolve prefixed elements //------------------------------------------------------------ SiteSummaryContentSyndicationExtension extension = new SiteSummaryContentSyndicationExtension(); XmlNamespaceManager manager = extension.CreateNamespaceManager(source); //------------------------------------------------------------ // Attempt to extract syndication information //------------------------------------------------------------ if (source.HasChildren) { XPathNavigator formatNavigator = source.SelectSingleNode("content:format", manager); XPathNavigator encodingNavigator = source.SelectSingleNode("content:encoding", manager); if (formatNavigator != null) { Uri format; if (Uri.TryCreate(formatNavigator.Value, UriKind.RelativeOrAbsolute, out format)) { this.Format = format; wasLoaded = true; } } if (encodingNavigator != null) { Uri encoding; if (Uri.TryCreate(encodingNavigator.Value, UriKind.RelativeOrAbsolute, out encoding)) { this.Encoding = encoding; wasLoaded = true; } } } if(!String.IsNullOrEmpty(source.Value)) { this.Content = source.Value; wasLoaded = true; } return wasLoaded; }