当前位置: 首页>>代码示例>>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;未经允许,请勿转载。