本文整理汇总了C#中System.Xml.XPath.XPathExpression.SetContext方法的典型用法代码示例。如果您正苦于以下问题:C# XPathExpression.SetContext方法的具体用法?C# XPathExpression.SetContext怎么用?C# XPathExpression.SetContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathExpression
的用法示例。
在下文中一共展示了XPathExpression.SetContext方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LiveExampleComponent
public LiveExampleComponent(BuildAssembler assembler, XPathNavigator configuration)
: base(assembler, configuration) {
XPathNavigator parsnip_node = configuration.SelectSingleNode("parsnip");
string approvedFile = null;
if (parsnip_node != null) {
approvedFile = parsnip_node.GetAttribute("approved-file", String.Empty);
string omitBadExamplesValue = parsnip_node.GetAttribute("omit-bad-examples", String.Empty);
if (!string.IsNullOrEmpty(omitBadExamplesValue))
omitBadExamples = Boolean.Parse(omitBadExamplesValue);
//string runBadExamplesValue = parsnip_node.GetAttribute("run-bad-examples", String.Empty);
//if (!string.IsNullOrEmpty(runBadExamplesValue))
// runBadExamples = Boolean.Parse(runBadExamplesValue);
}
if (string.IsNullOrEmpty(approvedFile))
WriteMessage(MessageLevel.Warn, "No approved samples file specified; all available samples will be included.");
else
LoadApprovedFile(approvedFile);
context = new CustomContext();
context.AddNamespace("ddue", "http://ddue.schemas.microsoft.com/authoring/2003/5");
selector = XPathExpression.Compile("//ddue:codeReference");
selector.SetContext(context);
}
示例2: Processor
static Processor()
{
XPathNavigator nav = new XmlDocument().CreateNavigator();
// Select all extension types.
Extensions = nav.Compile("/processing-instruction('extension')");
PostExts = nav.Compile("/processing-instruction('post-process')");
// Create and set namespace resolution context.
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nav.NameTable);
nsmgr.AddNamespace("xs", XmlSchema.Namespace);
nsmgr.AddNamespace("kzu", ExtensionNamespace);
Extensions.SetContext(nsmgr);
}
示例3: XmlSchemaParser
static XmlSchemaParser()
{
XPathNavigator nav = new XmlDocument().CreateNavigator();
// Select all extension types.
Extensions = nav.Compile( "/xs:schema/xs:annotation/xs:appinfo/kzu:Code/kzu:Extension/@Type" );
// Create and set namespace resolution context.
XmlNamespaceManager nsmgr = new XmlNamespaceManager( nav.NameTable );
nsmgr.AddNamespace( "xs", XmlSchema.Namespace );
nsmgr.AddNamespace( "kzu", ExtensionNamespace );
Extensions.SetContext( nsmgr );
}
示例4: Matches
public bool Matches(XPathExpression xpath, XPathNavigator source)
{
xpath = (XPathExpression)xpath.Clone();
xpath.SetContext(this);
return source.Matches(xpath);
}
示例5: SelectSingleNode
public XPathNavigator SelectSingleNode(XPathExpression xpath, XPathNavigator source)
{
xpath = (XPathExpression)xpath.Clone();
xpath.SetContext(this);
return source.SelectSingleNode(xpath);
}
示例6: Evaluate
public bool Evaluate(XPathExpression xpath, XPathNavigator source, out object result)
{
xpath = (XPathExpression)xpath.Clone();
xpath.SetContext(this);
result = source.Evaluate(xpath);
if (xpath.ReturnType == XPathResultType.NodeSet)
{
if (((XPathNodeIterator)result).Count == 0)
result = null;
}
return result != null;
}
示例7: findXPath
/// <summary>
/// This method sets the inherent XPathNodeIterator instance.
/// </summary>
/// <param name="xPath">A compiled XPath expression</param>
private void findXPath(XPathExpression xPath)
{
xPath.SetContext(_ParamContext);
_XIter = _XNav.Select(xPath);
InitializeCustomContext(_ParamContext);
}
示例8: Compile
internal void Compile(XPathNavigator nav)
{
if(Status == XPathSelectorStatus.Start)
{
GetXPath(nav);
}
if(Status == XPathSelectorStatus.Parsed)
{
xpath = nav.Compile(sXpath);
xpath.SetContext(GetNSManager());
Status = XPathSelectorStatus.Compiled;
}
}
示例9: FindXPath
/// <summary>
/// This method sets the inherent XPathNodeIterator instance.
/// </summary>
/// <param name="xPath">A compiled XPath expression</param>
private void FindXPath(XPathExpression xPath)
{
xPath.SetContext(_paramContext);
_xIter = _xNav.Select(xPath);
InitializeCustomContext(_paramContext);
}
示例10: Initialize
//=====================================================================
/// <inheritdoc />
public override void Initialize(XPathNavigator configuration)
{
XPathNodeIterator contentNodes = configuration.Select("examples");
foreach(XPathNavigator contentNode in contentNodes)
{
string file = contentNode.GetAttribute("file", String.Empty);
file = Environment.ExpandEnvironmentVariables(file);
if(String.IsNullOrEmpty(file))
WriteMessage(MessageLevel.Error, "Each examples element must contain a file attribute.");
LoadContent(file);
}
WriteMessage(MessageLevel.Info, "Loaded {0} code snippets", snippets.Count);
XPathNodeIterator colorsNodes = configuration.Select("colors");
foreach(XPathNavigator colorsNode in colorsNodes)
{
string language = colorsNode.GetAttribute("language", String.Empty);
List<ColorizationRule> rules = new List<ColorizationRule>();
XPathNodeIterator colorNodes = colorsNode.Select("color");
foreach(XPathNavigator colorNode in colorNodes)
{
string pattern = colorNode.GetAttribute("pattern", String.Empty);
string region = colorNode.GetAttribute("region", String.Empty);
string name = colorNode.GetAttribute("class", String.Empty);
if(String.IsNullOrEmpty(region))
rules.Add(new ColorizationRule(pattern, name));
else
rules.Add(new ColorizationRule(pattern, region, name));
}
colorization[language] = rules;
WriteMessage(MessageLevel.Info, "Loaded {0} colorization rules for the language '{1}'.", rules.Count, language);
}
context.AddNamespace("ddue", "http://ddue.schemas.microsoft.com/authoring/2003/5");
selector = XPathExpression.Compile("//ddue:codeReference");
selector.SetContext(context);
}
示例11: 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);
}
示例12: Evaluate
public override object Evaluate (XPathExpression expr, XPathNodeIterator context) {
expr.SetContext(nswrap);
return base.Evaluate(expr, context);
}
示例13: Select
public override XPathNodeIterator Select (XPathExpression expr) {
expr.SetContext(nswrap);
return base.Select(expr);
}
示例14: InitXPathExpression
protected void InitXPathExpression(string strXPathExpr, ref XPathExpression xpe)
{
XPathNavigator navigator = CreateNavigator();
xpe = navigator.Compile(strXPathExpr);
XmlNamespaceManager manager;
GetNamespaceManager(navigator, out manager);
xpe.SetContext(manager);
}