當前位置: 首頁>>代碼示例>>C#>>正文


C# XNode.ErrorContext方法代碼示例

本文整理匯總了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 );
                                  } );
        }
開發者ID:kascomp,項目名稱:CruiseControl.NET,代碼行數:27,代碼來源:ExpandSymbolProcessor.cs

示例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[] {};
 }
開發者ID:kascomp,項目名稱:CruiseControl.NET,代碼行數:23,代碼來源:DefineProcessor.cs

示例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));
     }
 }
開發者ID:kascomp,項目名稱:CruiseControl.NET,代碼行數:18,代碼來源:XHelpers.cs


注:本文中的System.Xml.Linq.XNode.ErrorContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。