当前位置: 首页>>代码示例>>C#>>正文


C# XNode.CreateReader方法代码示例

本文整理汇总了C#中System.Xml.Linq.XNode.CreateReader方法的典型用法代码示例。如果您正苦于以下问题:C# XNode.CreateReader方法的具体用法?C# XNode.CreateReader怎么用?C# XNode.CreateReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Linq.XNode的用法示例。


在下文中一共展示了XNode.CreateReader方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RuntimeOrderPipelinesProcessorConfiguration

 public RuntimeOrderPipelinesProcessorConfiguration(XNode xml)
 {
     if (xml == null) throw new ArgumentNullException("xml");
     using (var r = xml.CreateReader())
     {
         base.DeserializeElement(r, false);
     }
 }
开发者ID:enticify,项目名称:Enticify.Cs2009.Components,代码行数:8,代码来源:RuntimeOrderPipelinesProcessorConfiguration.cs

示例2: Transform

        static void Transform(string resourceName, XNode xml, ITaskItem outputFile)
        {
            var xmlTransform = new XslCompiledTransform();

            using (var writer = XmlWriter.Create(outputFile.GetMetadata("FullPath"), new XmlWriterSettings { Indent = true }))
            using (var xsltReader = XmlReader.Create(typeof(xunit).Assembly.GetManifestResourceStream("Xunit.Runner.MSBuild." + resourceName)))
            using (var xmlReader = xml.CreateReader())
            {
                xmlTransform.Load(xsltReader);
                xmlTransform.Transform(xmlReader, writer);
            }
        }
开发者ID:roczj,项目名称:xunit,代码行数:12,代码来源:xunit.cs

示例3: BuildElement


//.........这里部分代码省略.........
                    comm.ToBeOutput = true;
                }
                //comm.SetProperty("Content", comment); //dont call this method so that the comment is not "formatted"
                comm.Content = comment;
                return comm;
            }
            else if (node.NodeType == XmlNodeType.None || node.NodeType == XmlNodeType.Attribute ||
                //node.NodeType == XmlNodeType.ProcessingInstruction || 
                node.NodeType == XmlNodeType.Entity ||
                node.NodeType == XmlNodeType.Document || node.NodeType == XmlNodeType.DocumentFragment ||
                node.NodeType == XmlNodeType.DocumentType || node.NodeType == XmlNodeType.Notation ||
                node.NodeType == XmlNodeType.Whitespace || node.NodeType == XmlNodeType.EndElement ||
                node.NodeType == XmlNodeType.EndEntity || node.NodeType == XmlNodeType.XmlDeclaration
                || node.NodeType == XmlNodeType.SignificantWhitespace)
            {
                Nothing nothing = new Nothing();
                nothing.Document = this;
                nothing.Line = lineInfo.LineNumber;
                nothing.Column = lineInfo.LinePosition;
                return nothing;
            }

            if (!(node is XElement))
                throw new QuicException(string.Format("Unrecognized XML node '{0}'", node), 
                    this.SourcePath, lineInfo.LineNumber, lineInfo.LinePosition);
            XElement elementNode = (XElement)node;
            Element element = null;
            try
            {
                element = (Element)BuildObject(elementNode.Name.LocalName, elementNode.GetPrefixOfNamespace(elementNode.Name.Namespace));
                element.Document = this; //just in case I delete it from BuildObject(...) by mistake
            }
            catch (TypeLoadException ex)
            {
                if (this.OutputOptions.AllowUnknownTags)
                {
                    element = new UnknownElement();
                    element.Document = this;
                    var prefix = elementNode.GetPrefixOfNamespace(elementNode.Name.Namespace);
                    ((UnknownElement)element).Tag = (string.IsNullOrWhiteSpace(prefix) ? "" : prefix + ":") + elementNode.Name.LocalName;
                    ((UnknownElement)element).IsEmptyTag = elementNode.IsEmpty;
                }
                else
                {
                    throw new QuicException(ex.Message, this.SourcePath, lineInfo.LineNumber, lineInfo.LinePosition, ex);
                }
            }
            catch (QuicException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new QuicException(ex.Message, this.SourcePath, lineInfo.LineNumber, lineInfo.LinePosition, ex);
            }
            element.Line = lineInfo.LineNumber;
            element.Column = lineInfo.LinePosition;

            //set its properties
            foreach (XAttribute attri in elementNode.Attributes())
            {
                //try
                //{
                if (!attri.IsNamespaceDeclaration)
                    element.SetProperty(attri.Name.LocalName, attri.Value);
                //}
                //catch (Exception ex)
                //{
                //    var attriLineInfo = (IXmlLineInfo)attri;
                //    throw new QuicException(ex.Message, this.SourcePath, attriLineInfo.LineNumber, attriLineInfo.LinePosition, ex);
                //}
            }
            //record the element if it has a name
            if (element.Name != null)
            {
                if (namedElements.ContainsKey(element.Name))
                    throw new QuicException(string.Format("An element with the name '{0}' already exists.", element.Name),
                        this.SourcePath, element.Line, element.Column);
                namedElements.Add(element.Name, element);
            }
            //child tags
            if ((element).IsContainer)
            {
                foreach (XNode child in elementNode.Nodes())
                {
                    var uiElement = BuildElement(child);
                    (element).Elements.Add(uiElement);
                }
            }
            else
            {
                var reader = node.CreateReader();
                reader.MoveToContent();
                string innerXml = reader.ReadInnerXml();
                //((UIElement)element).Content = innerXml;
                element.SetProperty("Content", innerXml);
            }

            return element;
        }
开发者ID:Chieze-Franklin,项目名称:Quic,代码行数:101,代码来源:QuicDocument.cs

示例4: XmlOutput

 public XmlOutput(XNode element)
 {
     navigator = new XPathDocument(element.CreateReader()).CreateNavigator();
     manager = new XmlNamespaceManager(navigator.NameTable);
     manager.AddNamespace("r", Namespaces.ShopSchema.NamespaceName);
     manager.AddNamespace("x", Namespaces.XForms.NamespaceName);
 }
开发者ID:iansrobinson,项目名称:Restbucks,代码行数:7,代码来源:ShopFormatterTests.cs

示例5: WriteToFile

 private void WriteToFile( XNode doc, StreamWriter file )
 {
     try
     {
         XmlReader xr = doc.CreateReader( ) ;
         Stylesheet.Transform( xr, null, file.BaseStream ) ;
     }
     catch ( XsltException e )
     {
         Trace.TraceError( e.Message ) ;
         throw ;
     }
 }
开发者ID:svn2github,项目名称:bindablelinq,代码行数:13,代码来源:FileSystemService.cs

示例6: GetContentToEncrypt

 private string GetContentToEncrypt(XNode element)
 {
     var reader = element.CreateReader();
     reader.MoveToContent();
     return reader.ReadInnerXml();
 }
开发者ID:mRemoteNG,项目名称:mRemoteNG,代码行数:6,代码来源:XmlConnectionsDocumentEncryptor.cs

示例7: ConstantExpression

        public ConstantExpression(XNode value)
            : this(value, DbType.AnsiStringFixedLength)
        {
            if (value == null) {
                throw new ArgumentNullException(
                    "value",
                    "The value passed to a constant XNode expression must not be null");
            }

            // TODO reader is IDisposable remove that from here
            this.Value = new SqlXml(value.CreateReader());
            this.DbType = DbType.Xml;
        }
开发者ID:codeinsiders,项目名称:sharpql,代码行数:13,代码来源:ConstantExpression.cs


注:本文中的System.Xml.Linq.XNode.CreateReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。