本文整理匯總了C#中System.Xml.Linq.XNode.ErrorContext方法的典型用法代碼示例。如果您正苦於以下問題:C# XNode.ErrorContext方法的具體用法?C# XNode.ErrorContext怎麽用?C# XNode.ErrorContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.Linq.XNode
的用法示例。
在下文中一共展示了XNode.ErrorContext方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Process
public override IEnumerable< XNode > Process(XNode node)
{
XElement element = _AssumeElement( node );
string symbol_name = element.Name.LocalName;
if ( !_Env.IsDefined( symbol_name ) )
throw InvalidMarkupException.CreateException( "[{0}] Undefined symbol '{1}' ",
node.ErrorContext(),
element.Name );
/* Evaluate the symbol on a new stack frame, since we may be defining local symbols
* based on the attributes */
return _Env.Call( () =>
{
/* Bind attributes as local symbolic definitions */
_DefineFromAttributes( element );
/* Bind any nested definition elements */
_ProcessNodes(
element.Elements( _Env._Settings.Namespace.GetName("define") ).Select
( n => ( XNode ) n ) );
// Must materialize the deferred-execution nodeset
// iterator before this method returns, otherwise
// the evaluation stack will be wrong. Calling ToArray()
// ensures this.
return _Env.EvalSymbol( symbol_name ).ToArray();
//return _ProcessNodes( ret );
} );
}
示例2: Process
public override IEnumerable< XNode > Process(XNode node)
{
XElement element = _AssumeElement( node );
// If "define" element has a "name" attribute, treat the element contents as a nodeset definition.
if ( element.HasAttribute( AttrName.Name ) )
{
_Env.DefineNodesetSymbol( ( string ) element.Attribute( AttrName.Name ),
element.Nodes() );
}
// ...otherwise treat each attribute as a separate text definition of the form "name=value"
else if ( element.HasAttributes )
{
_DefineFromAttributes( element );
}
else
{
throw DefinitionException.CreateException(
"{0} <define> element has no attributes.",
node.ErrorContext() );
}
/* Define produces no output */
return new XNode[] {};
}
示例3: _ValueOf
private static string _ValueOf(XNode node)
{
switch (node.NodeType)
{
case XmlNodeType.Element:
return ((XElement)node).Value;
case XmlNodeType.Text:
return ((XText)node).Value;
case XmlNodeType.Comment:
case XmlNodeType.ProcessingInstruction:
return String.Empty;
default:
throw new InvalidOperationException(
string.Format(System.Globalization.CultureInfo.CurrentCulture,"{0} Unhandled node type {1}",
node.ErrorContext(),
node.NodeType));
}
}