本文整理汇总了C#中System.Xml.XPath.XPathNavigator.Matches方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.Matches方法的具体用法?C# XPathNavigator.Matches怎么用?C# XPathNavigator.Matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.Matches方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNodeXPath
public override string GetNodeXPath (XPathNavigator n)
{
if (n.Matches ("/Type/Docs/param")) {
string type_name = (string) n.Evaluate ("string (ancestor::Type/@FullName)");
string param_name = (string) n.Evaluate ("string (@name)");
return String.Format ("/Type [@FullName = '{0}']/Docs/param[@name='{1}']", type_name, param_name);
}
if (n.Matches ("/Type/Docs/*")) {
string type_name = (string) n.Evaluate ("string (ancestor::Type/@FullName)");
return String.Format ("/Type [@FullName = '{0}']/Docs/{1}", type_name, n.Name);
}
if (n.Matches ("/Type/Members/Member/Docs/*")) {
string type_name = (string) n.Evaluate ("string (ancestor::Type/@FullName)");
string member_name = (string) n.Evaluate ("string (ancestor::Member/@MemberName)");
string member_sig = (string) n.Evaluate ("string (ancestor::Member/MemberSignature [@Language='C#']/@Value)");
string param_name = (string) n.Evaluate ("string (@name)");
if (param_name == null || param_name == "") {
return String.Format (
"/Type [@FullName = '{0}']/Members/Member [@MemberName = '{1}'][MemberSignature [@Language='C#']/@Value = '{2}']/Docs/{3}",
type_name, member_name, member_sig, n.Name);
} else {
return String.Format (
"/Type [@FullName = '{0}']/Members/Member [@MemberName = '{1}'][MemberSignature [@Language='C#']/@Value = '{2}']/Docs/param [@name = '{3}']",
type_name, member_name, member_sig, param_name);
}
}
Message (TraceLevel.Warning, "WARNING: Was not able to get clean XPath expression for node {0}", EditingUtils.GetXPath (n));
return base.GetNodeXPath (n);
}
示例2: Matches
public bool Matches(XPathExpression xpath, XPathNavigator source)
{
xpath = (XPathExpression)xpath.Clone();
xpath.SetContext(this);
return source.Matches(xpath);
}
示例3: Matches
public bool Matches(XPathNavigator nav)
{
if(Status != XPathSelectorStatus.Compiled)
{
Compile(nav);
}
if(Status == XPathSelectorStatus.Compiled)
{
try
{
return nav.Matches(xpath);
}
catch
{
return false;
}
}
else
{
return false;
}
}
示例4: MatchNode
/// <summary>
/// Matches given node against "match" pattern and adds it to
/// the index table if the matching succeeded.
/// </summary>
/// <param name="node">Node to match</param>
public void MatchNode(XPathNavigator node)
{
foreach (KeyDef keyDef in keys)
{
if (node.Matches(keyDef.MatchExpr))
{
//Ok, let's calculate key value(s). As per XSLT spec:
//If the result is a node-set, then for each node in the node-set,
//the node that matches the pattern has a key of the specified name whose
//value is the string-value of the node in the node-set; otherwise, the result
//is converted to a string, and the node that matches the pattern has a
//key of the specified name with value equal to that string.
object key = node.Evaluate(keyDef.UseExpr);
if (key is XPathNodeIterator)
{
XPathNodeIterator ni = (XPathNodeIterator)key;
while (ni.MoveNext())
AddNodeToIndex(node, ni.Current.Value);
}
else
{
AddNodeToIndex(node, key.ToString());
}
}
}
}
示例5: Matches
internal bool Matches(XPathNavigator context, int key) {
return context.Matches(GetValueQuery(key));
}
示例6: IsMatch
public bool IsMatch(XPathNavigator xpn, XmlNamespaceManager xnm)
{
if ( xpathExpression == null )
{
xpathExpression=xpn.Compile(xpath);
xpathExpression.SetContext(xnm);
}
return xpn.Matches(xpathExpression);
// Debug.Assert(e.Name.Equals(name), "IsMatch called for incorrect element!");
// // TODO: L: bit messy
// return Conditions == null || Conditions.Conditions ==null ||
// Conditions.Conditions.Count == 0 || Conditions.MatchesAll(e);
}