當前位置: 首頁>>代碼示例>>C#>>正文


C# XPathNavigator.GetAllNamespaces方法代碼示例

本文整理匯總了C#中System.Xml.XPath.XPathNavigator.GetAllNamespaces方法的典型用法代碼示例。如果您正苦於以下問題:C# XPathNavigator.GetAllNamespaces方法的具體用法?C# XPathNavigator.GetAllNamespaces怎麽用?C# XPathNavigator.GetAllNamespaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XPath.XPathNavigator的用法示例。


在下文中一共展示了XPathNavigator.GetAllNamespaces方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ExistsInSource

        /// <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;
        }
開發者ID:kodefuguru,項目名稱:SDataCSharpClientLib,代碼行數:47,代碼來源:SyndicationExtension.cs


注:本文中的System.Xml.XPath.XPathNavigator.GetAllNamespaces方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。