/// <summary> /// Determines if the <see cref="SyndicationExtension"/> exists in the XML data in the supplied <see cref="XPathNavigator"/>. /// </summary> /// <param name="source">The <see cref="XPathNavigator"/> to parse.</param> /// <returns><b>true</b> if the <see cref="SyndicationExtension"/> elements or attributes are present in the <paramref name="source"/>; otherwise <b>false</b>.</returns> /// <remarks> /// <para> /// This method should be as lightweight as possible when determining if the <see cref="SyndicationExtension"/> or its related entities are present in the <paramref name="source"/>. /// The default implementation utilizes the <see cref="XPathNavigator.GetNamespacesInScope(XmlNamespaceScope)"/> method to determine if the <paramref name="source"/> contains /// the expected namespace(s) for this <see cref="SyndicationExtension"/>. /// </para> /// <para>It is recommended that you call this method prior to executing a possibly costly load operation using the <see cref="SyndicationExtension.Load(IXPathNavigable)"/> method.</para> /// </remarks> public virtual bool ExistsInSource(XPathNavigator source) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ bool extensionExists = false; //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(source, "source"); //------------------------------------------------------------ // Determine if extension exists //------------------------------------------------------------ //BEGIN PATCH //Dictionary<string, string> namespaces = (Dictionary<string, string>)source.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml); //if (namespaces.ContainsValue(this.XmlNamespace)) //{ // extensionExists = true; //} //else if (namespaces.ContainsKey(this.XmlPrefix)) //{ // extensionExists = true; //} var namespaces = source.GetAllNamespaces(); if (namespaces.Any(item => item.Value == this.XmlNamespace) || namespaces.Any(item => item.Key == this.XmlPrefix)) { extensionExists = true; } //END PATCH return extensionExists; }