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


C# IO.XmlReader类代码示例

本文整理汇总了C#中System.IO.XmlReader的典型用法代码示例。如果您正苦于以下问题:C# XmlReader类的具体用法?C# XmlReader怎么用?C# XmlReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XmlReader类属于System.IO命名空间,在下文中一共展示了XmlReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: XDeclaration

 internal XDeclaration(XmlReader r)
 {
     _version = r.GetAttribute("version");
     _encoding = r.GetAttribute("encoding");
     _standalone = r.GetAttribute("standalone");
     r.Read();
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:7,代码来源:XDeclaration.cs

示例2: StartParsing

        public void StartParsing(XmlReader reader, string targetNamespace) {
            this.reader = reader;
            positionInfo = PositionInfo.GetPositionInfo(reader);
            namespaceManager = reader.NamespaceManager;
            if (namespaceManager == null) {
                namespaceManager = new XmlNamespaceManager(nameTable);
                isProcessNamespaces = true;
            } 
            else {
                isProcessNamespaces = false;
            }
            while (reader.NodeType != XmlNodeType.Element && reader.Read()) {}

            markupDepth = int.MaxValue;
            schemaXmlDepth = reader.Depth;
            SchemaType rootType = schemaNames.SchemaTypeFromRoot(reader.LocalName, reader.NamespaceURI);
            
            string code;
            if (!CheckSchemaRoot(rootType, out code)) {
                throw new XmlSchemaException(code, reader.BaseURI, positionInfo.LineNumber, positionInfo.LinePosition);
            }
            
            if (schemaType == SchemaType.XSD) {
                schema = new XmlSchema();
                schema.BaseUri = new Uri(reader.BaseURI, UriKind.RelativeOrAbsolute);
                builder = new XsdBuilder(reader, namespaceManager, schema, nameTable, schemaNames, eventHandler);
            }
            else {  
                Debug.Assert(schemaType == SchemaType.XDR);
                xdrSchema = new SchemaInfo();
                xdrSchema.SchemaType = SchemaType.XDR;
                builder = new XdrBuilder(reader, namespaceManager, xdrSchema, targetNamespace, nameTable, schemaNames, eventHandler);
                ((XdrBuilder)builder).XmlResolver = xmlResolver;
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:35,代码来源:Parser.cs

示例3: XmlCountingReader

 internal XmlCountingReader(XmlReader xmlReader) 
 {
     if (xmlReader == null)
         throw new ArgumentNullException("xmlReader");
     this.innerReader = xmlReader;
     this.advanceCount = 0;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:XmlCountingReader.cs

示例4: XmlCountingReader

 internal XmlCountingReader(XmlReader xmlReader)
 {
     if (xmlReader == null)
         throw new ArgumentNullException(nameof(xmlReader));
     _innerReader = xmlReader;
     _advanceCount = 0;
 }
开发者ID:geoffkizer,项目名称:corefx,代码行数:7,代码来源:XmlCountingReader.cs

示例5: StartParsing

        internal void StartParsing(XmlReader reader, string targetNamespace, SchemaInfo schemaInfo) {
            this.reader = reader;
            positionInfo = PositionInfo.GetPositionInfo(reader);
            this.namespaceManager = reader.NamespaceManager;
            if (this.namespaceManager == null) {
                this.namespaceManager = new XmlNamespaceManager(this.nameTable);
                this.isProcessNamespaces = true;
            } 
            else {
                this.isProcessNamespaces = false;
            }
            while (this.reader.NodeType != XmlNodeType.Element && this.reader.Read()) {}

            this.markupDepth = int.MaxValue;
			this.schemaXmlDepth = reader.Depth;
            XmlQualifiedName qname = new XmlQualifiedName(this.reader.LocalName, XmlSchemaDatatype.XdrCanonizeUri(this.reader.NamespaceURI, this.nameTable, this.schemaNames));
            if (this.schemaNames.IsXDRRoot(qname)) {
                Debug.Assert(schemaInfo != null);
                schemaInfo.SchemaType = SchemaType.XDR;
                this.schema = null;
                this.builder = new XdrBuilder(reader, this.namespaceManager, schemaInfo, targetNamespace, this.nameTable, this.schemaNames, this.validationEventHandler);
            }
            else if (this.schemaNames.IsXSDRoot(qname)) {
                if (schemaInfo != null) {
                    schemaInfo.SchemaType = SchemaType.XSD;
                }
                this.schema = new XmlSchema();
                this.schema.BaseUri = reader.BaseURI;
                this.builder = new XsdBuilder(reader, this.namespaceManager, this.schema, this.nameTable, this.schemaNames, this.validationEventHandler);
            }
            else { 
                throw new XmlSchemaException(Res.Sch_SchemaRootExpected, reader.BaseURI, positionInfo.LineNumber, positionInfo.LinePosition);
            }
                
        }
开发者ID:ArildF,项目名称:masters,代码行数:35,代码来源:parser.cs

示例6: XPathDocument

        /// <summary>
        /// Create a new document from "reader", with whitespace handling controlled according to "space".
        /// </summary>
        public XPathDocument(XmlReader reader, XmlSpace space)
        {
            if (reader == null)
                throw new ArgumentNullException(nameof(reader));

            LoadFromReader(reader, space);
        }
开发者ID:Corillian,项目名称:corefx,代码行数:10,代码来源:XPathDocument.cs

示例7: Load

 public void Load(XmlReader stylesheet, XmlResolver resolver)
 {
     if (stylesheet == null)
     {
         throw new ArgumentNullException(nameof(stylesheet));
     }
     Load(new XPathDocument(stylesheet, XmlSpace.Preserve), resolver);
 }
开发者ID:alessandromontividiu03,项目名称:corefx,代码行数:8,代码来源:XslTransform.cs

示例8: XmlCustomReader

 public XmlCustomReader(TextReader textReader, XmlReaderSettings settings, string baseUri)
 {
     XmlReader w = ReaderHelper.Create(textReader, settings, baseUri);
     XmlReaderSettings wsettings = new XmlReaderSettings();
     wsettings.CheckCharacters = true;
     wsettings.DtdProcessing = DtdProcessing.Ignore;
     wsettings.ConformanceLevel = ConformanceLevel.Auto;
     _wrappedreader = ReaderHelper.Create(w, wsettings);
 }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:9,代码来源:CReader.cs

示例9: Init

 private void Init( XmlReader reader ) {
     XmlValidatingReader vr = null;
     try {
         vr = new XmlValidatingReader( reader );
         vr.EntityHandling = EntityHandling.ExpandEntities;
         vr.ValidationType = ValidationType.None;
         vr.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
         Load( vr );
     }
     finally {
         vr.Close();
         reader.Close();
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:14,代码来源:xpathdocument.cs

示例10: CheckIgnores

        public bool CheckIgnores(XmlReader reader, bool pi, bool comm, bool ws)
        {
            if (reader == null)
                return false;

            _commentCount = 0;
            _piCount = 0;
            _wsCount = 0;

            while (reader.Read())
            {
                if (XmlNodeType.ProcessingInstruction == reader.NodeType)
                {
                    ++_piCount;
                }
                if (XmlNodeType.SignificantWhitespace == reader.NodeType)
                {
                    ++_wsCount;
                }
                if (XmlNodeType.Comment == reader.NodeType)
                {
                    ++_commentCount;
                }
            }

            if (pi && _piCount > 0)
            {
                CError.WriteLineIgnore("ProcessingInstruction Found");
                CError.WriteLineIgnore(reader.Name);
                CError.WriteLineIgnore(">" + reader.Value + "<");
                return false;
            }
            if (comm && _commentCount > 0)
            {
                CError.WriteLineIgnore("Comment Found");
                CError.WriteLineIgnore(reader.Name);
                CError.WriteLineIgnore(">" + reader.Value + "<");
                return false;
            }
            if (ws && _wsCount > 0)
            {
                CError.WriteLineIgnore("Significant Whitespace Found");
                CError.WriteLineIgnore(reader.Name);
                CError.WriteLineIgnore(">" + reader.Value + "<");
                return false;
            }
            return true;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:48,代码来源:FilterSettings.cs

示例11: StartParsingAsync

        public async Task StartParsingAsync(XmlReader reader, string targetNamespace)
        {
            _reader = reader;
            _positionInfo = PositionInfo.GetPositionInfo(reader);
            _namespaceManager = reader.NamespaceManager;
            if (_namespaceManager == null)
            {
                _namespaceManager = new XmlNamespaceManager(_nameTable);
                _isProcessNamespaces = true;
            }
            else
            {
                _isProcessNamespaces = false;
            }
            while (reader.NodeType != XmlNodeType.Element && await reader.ReadAsync().ConfigureAwait(false)) { }

            _markupDepth = int.MaxValue;
            _schemaXmlDepth = reader.Depth;
            SchemaType rootType = _schemaNames.SchemaTypeFromRoot(reader.LocalName, reader.NamespaceURI);

            string code;
            if (!CheckSchemaRoot(rootType, out code))
            {
                throw new XmlSchemaException(code, reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition);
            }

            if (_schemaType == SchemaType.XSD)
            {
                _schema = new XmlSchema();
                _schema.BaseUri = new Uri(reader.BaseURI, UriKind.RelativeOrAbsolute);
                _builder = new XsdBuilder(reader, _namespaceManager, _schema, _nameTable, _schemaNames, _eventHandler);
            }
            else
            {
                Debug.Assert(_schemaType == SchemaType.XDR);
                _xdrSchema = new SchemaInfo();
                _xdrSchema.SchemaType = SchemaType.XDR;
                _builder = new XdrBuilder(reader, _namespaceManager, _xdrSchema, targetNamespace, _nameTable, _schemaNames, _eventHandler);
                ((XdrBuilder)_builder).XmlResolver = _xmlResolver;
            }
        }
开发者ID:Corillian,项目名称:corefx,代码行数:41,代码来源:ParserAsync.cs

示例12: CanDeserialize

        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public virtual bool CanDeserialize(XmlReader xmlReader)
        {
            if (_primitiveType != null)
            {
                TypeDesc typeDesc = (TypeDesc)TypeScope.PrimtiveTypes[_primitiveType];
                return xmlReader.IsStartElement(typeDesc.DataType.Name, string.Empty);
            }
#if !NET_NATIVE
            else if (_tempAssembly != null)
            {
                return _tempAssembly.CanRead(_mapping, xmlReader);
            }
            else
            {
                return false;
            }
#else
            if (this.innerSerializer != null)
            {
                return this.innerSerializer.CanDeserialize(xmlReader);
            }
            else
            {
                return ReflectionMethodEnabled;
            }
#endif
        }
开发者ID:SamuelEnglard,项目名称:corefx,代码行数:30,代码来源:XmlSerializer.cs

示例13: Deserialize

        internal object Deserialize(XmlReader xmlReader, string encodingStyle, XmlDeserializationEvents events)
        {
            try
            {
                if (_primitiveType != null)
                {
                    return DeserializePrimitive(xmlReader, events);
                }
#if !NET_NATIVE
                else if (Mode == SerializationMode.ReflectionOnly)
                {
                    XmlMapping mapping;
                    if (_mapping.GenerateSerializer)
                    {
                        mapping = _mapping;
                    }
                    else
                    {
                        XmlReflectionImporter importer = new XmlReflectionImporter(DefaultNamespace);
                        mapping = importer.ImportTypeMapping(rootType, null, DefaultNamespace);
                    }

                    var reader = new ReflectionXmlSerializationReader(mapping, xmlReader, events, encodingStyle);
                    return reader.ReadObject();
                }
                else if (_tempAssembly == null || _typedSerializer)
                {
                    XmlSerializationReader reader = CreateReader();
                    reader.Init(xmlReader, events, encodingStyle, _tempAssembly);
                    try
                    {
                        return Deserialize(reader);
                    }
                    finally
                    {
                        reader.Dispose();
                    }
                }
                else
                {
                    return _tempAssembly.InvokeReader(_mapping, xmlReader, events, encodingStyle);
                }
#else
                else
                {
                    if (this.innerSerializer != null)
                    {
                        if (!string.IsNullOrEmpty(this.DefaultNamespace))
                        {
                            this.innerSerializer.DefaultNamespace = this.DefaultNamespace;
                        }

                        XmlSerializationReader reader = this.innerSerializer.CreateReader();
                        reader.Init(xmlReader, encodingStyle);
                        try
                        {
                            return this.innerSerializer.Deserialize(reader);
                        }
                        finally
                        {
                            reader.Dispose();
                        }
                    }
                    else if (ReflectionMethodEnabled)
                    {
                        XmlMapping mapping;
                        if (_mapping != null && _mapping.GenerateSerializer)
                        {
                            mapping = _mapping;
                        }
                        else
                        {
                            XmlReflectionImporter importer = new XmlReflectionImporter(DefaultNamespace);
                            mapping = importer.ImportTypeMapping(rootType, null, DefaultNamespace);
                        }

                        var reader = new ReflectionXmlSerializationReader(mapping, xmlReader, events, encodingStyle);
                        return reader.ReadObject();
                    }
                    else
                    {

                        throw new InvalidOperationException(SR.Format(SR.Xml_MissingSerializationCodeException, this.rootType, typeof(XmlSerializer).Name));
                    }
                }
#endif
            }
            catch (Exception e)
            {
                if (e is TargetInvocationException)
                    e = e.InnerException;

                if (xmlReader is IXmlLineInfo)
                {
                    IXmlLineInfo lineInfo = (IXmlLineInfo)xmlReader;
                    throw new InvalidOperationException(SR.Format(SR.XmlSerializeErrorDetails, lineInfo.LineNumber.ToString(CultureInfo.InvariantCulture), lineInfo.LinePosition.ToString(CultureInfo.InvariantCulture)), e);
                }
                else
                {
                    throw new InvalidOperationException(SR.XmlSerializeError, e);
//.........这里部分代码省略.........
开发者ID:SamuelEnglard,项目名称:corefx,代码行数:101,代码来源:XmlSerializer.cs

示例14: Execute

        /// <summary>
        /// Executes the query by accessing datasources via the XmlResolver and using run-time parameters
        /// as provided by the XsltArgumentList. The default document is mapped into the XmlResolver with the
        /// provided name. The results are output to the provided Stream.
        /// </summary>
        public override void Execute(XmlReader contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, Stream results) {
            if (results == null)
                throw new ArgumentNullException(nameof(results));

            Execute(contextDocument, dataSources, argumentList, XmlWriter.Create(results, this.staticData.DefaultWriterSettings), true);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:11,代码来源:XmlILCommand.cs

示例15: NestRead

 private XmlReader NestRead(XmlReader r)
 {
     r.Read();
     r.Read();
     if (!(r.Name == "elem0" && r.NodeType == XmlNodeType.Element))
     {
         CError.WriteLine(r.Name);
         NestRead(r.ReadSubtree());
     }
     r.Dispose();
     return r;
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:12,代码来源:ReadSubTree.cs


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