Class DynamicContext
Provides the evaluation context for fast execution and custom variables resolution.
Inheritance
Namespace: Umbraco.Cms.Core.Xml
Assembly: Umbraco.Core.dll
Syntax
public class DynamicContext : XsltContext, IEnumerable, IXmlNamespaceResolver
Remarks
This class is responsible for resolving variables during dynamic expression execution.
Discussed in http://weblogs.asp.net/cazzu/archive/2003/10/07/30888.aspx
Author: Daniel Cazzulino, blog
Constructors
View SourceDynamicContext()
Initializes a new instance of the DynamicContext class.
Declaration
public DynamicContext()
DynamicContext(NameTable)
Initializes a new instance of the DynamicContext class with the specified System.Xml.NameTable.
Declaration
public DynamicContext(NameTable table)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.NameTable | table | The NameTable to use. |
DynamicContext(XmlNamespaceManager)
Initializes a new instance of the DynamicContext class.
Declaration
public DynamicContext(XmlNamespaceManager context)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlNamespaceManager | context | A previously filled context with the namespaces to use. |
DynamicContext(XmlNamespaceManager, NameTable)
Initializes a new instance of the DynamicContext class.
Declaration
public DynamicContext(XmlNamespaceManager context, NameTable table)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlNamespaceManager | context | A previously filled context with the namespaces to use. |
| System.Xml.NameTable | table | The NameTable to use. |
Properties
View SourceWhitespace
Same as System.Xml.Xsl.XsltContext.
Declaration
public override bool Whitespace { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
View SourceAddVariable(String, Object)
Adds the variable to the dynamic evaluation context.
Declaration
public void AddVariable(string name, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the variable to add to the context. |
| System.Object | value | The value of the variable to add to the context. |
Remarks
Value type conversion for XPath evaluation is as follows:
| CLR Type | XPath type |
|---|---|
| System.String | XPathResultType.String |
| System.Double (or types that can be converted to) | XPathResultType.Number |
| System.Boolean | XPathResultType.Boolean |
| System.Xml.XPath.XPathNavigator | XPathResultType.Navigator |
| System.Xml.XPath.XPathNodeIterator | XPathResultType.NodeSet |
| Others | XPathResultType.Any |
note
See the topic "Compile, Select, Evaluate, and Matches with XPath and XPathExpressions" in MSDN documentation for additional information.
CompareDocument(String, String)
Implementation equal to System.Xml.Xsl.XsltContext.
Declaration
public override int CompareDocument(string baseUri, string nextbaseUri)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | baseUri | |
| System.String | nextbaseUri |
Returns
| Type | Description |
|---|---|
| System.Int32 |
Compile(String)
Shortcut method that compiles an expression using an empty navigator.
Declaration
public static XPathExpression Compile(string xpath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | xpath | The expression to compile |
Returns
| Type | Description |
|---|---|
| System.Xml.XPath.XPathExpression | A compiled System.Xml.XPath.XPathExpression. |
LookupNamespace(String)
Same as System.Xml.XmlNamespaceManager.
Declaration
public override string LookupNamespace(string prefix)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | prefix |
Returns
| Type | Description |
|---|---|
| System.String |
LookupPrefix(String)
Same as System.Xml.XmlNamespaceManager.
Declaration
public override string LookupPrefix(string uri)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | uri |
Returns
| Type | Description |
|---|---|
| System.String |
PreserveWhitespace(XPathNavigator)
Same as System.Xml.Xsl.XsltContext.
Declaration
public override bool PreserveWhitespace(XPathNavigator node)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XPath.XPathNavigator | node |
Returns
| Type | Description |
|---|---|
| System.Boolean |
ResolveFunction(String, String, XPathResultType[])
See System.Xml.Xsl.XsltContext. Not used in our implementation.
Declaration
public override IXsltContextFunction ResolveFunction(string prefix, string name, XPathResultType[] argTypes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | prefix | |
| System.String | name | |
| System.Xml.XPath.XPathResultType[] | argTypes |
Returns
| Type | Description |
|---|---|
| System.Xml.Xsl.IXsltContextFunction |
ResolveVariable(String, String)
Resolves the dynamic variables added to the context. See System.Xml.Xsl.XsltContext.
Declaration
public override IXsltContextVariable ResolveVariable(string prefix, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | prefix | |
| System.String | name |
Returns
| Type | Description |
|---|---|
| System.Xml.Xsl.IXsltContextVariable |