本文整理汇总了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;
}