// All settings remain the same. /// <include file='doc\xmltextreader.uex' path='docs/doc[@for="XmlTextReader.ResetState"]/*' /> public void ResetState() { if (XmlNodeType.None != _PartialContentNodeType) { throw new InvalidOperationException(Res.GetString(Res.Xml_InvalidResetStateCall)); } if (ReadState.Initial == ReadState) { //noop. we are already at the begining of the document return; } _ReadState = ReadState.Initial; _RootCount = 0; ResetFieldsCollection(); _Scanner.Reset(); _NextFunction = _ParseRootIndex; _DtdParser = null; _TmpToken = new XmlNSElementTokenInfo(_Scanner, _NsMgr, XmlNodeType.None, String.Empty,-1, -1, -1, 0,false); _CurrentToken = _TmpToken; _CantHaveXmlDecl = false; _Encoding = _Scanner.Encoding; // // pop all the pushed elements // while (Pop() != null) ; }
private void Init() { if (_Scanner == null) { CreateScanner(); } _Scanner.Normalization = Normalization; _Scanner.NamespaceSupport = _CheckNamespaces; if (_Encoding == null) { _Encoding = _Scanner.Encoding; } _TextToken = new XmlWSTokenInfo(_Scanner, _NsMgr, XmlNodeType.Text, -1, _Normalization); _WhitespaceToken = new XmlWSTokenInfo(_Scanner, _NsMgr, XmlNodeType.Whitespace, -1, _Normalization); _ERToken = new XmlNameValueTokenInfo(_Scanner, _NsMgr, XmlNodeType.EntityReference, -1, String.Empty, false); if (_CheckNamespaces) { _TmpToken = new XmlNSElementTokenInfo(_Scanner, _NsMgr, XmlNodeType.None, String.Empty,-1, -1, -1, 0,false); _ElementToken = new XmlNSElementTokenInfo(_Scanner, _NsMgr, XmlNodeType.Element, String.Empty,-1, -1, -1, -1,false); _EndElementToken = new XmlNSElementTokenInfo(_Scanner, _NsMgr, XmlNodeType.EndElement, String.Empty,-1, -1, -1, -1,false); _AttributeTextToken = new XmlNSAttributeTokenInfo(_Scanner, _NsMgr, XmlNodeType.Text, _Normalization, _XmlNs); } else { _TmpToken = new XmlElementTokenInfo(_Scanner, _NsMgr, XmlNodeType.None, String.Empty,-1, -1, -1, 0, false); _ElementToken = new XmlElementTokenInfo(_Scanner, _NsMgr, XmlNodeType.Element, String.Empty,-1, -1, -1, -1, false); _EndElementToken = new XmlElementTokenInfo(_Scanner, _NsMgr, XmlNodeType.Element, String.Empty,-1, -1, -1, -1, false); _AttributeTextToken = new XmlAttributeTokenInfo(_Scanner, _NsMgr, XmlNodeType.Text, _Normalization); } _CurrentToken = _TmpToken; }
// protected constructor, users should not be using this /// <include file='doc\XmlTextReader.uex' path='docs/doc[@for="XmlTextReader.XmlTextReader1"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Initializes a new instance of the XmlTextReader class with the specified XmlNameTable.</para> /// </devdoc> protected XmlTextReader( XmlNameTable nt ) { // // internal variables // _ElementDepth = -1; _EntityDepthOffset = 0; _ReadCount = -1; // // variables for properties // _ReadState = ReadState.Initial; _NextState = 1; // // create interal components // _NameTable = nt; _ElementStack = new HWStack(STACK_INCREMENT); _ScannerStack = new HWStack(STACK_INCREMENT); // //create atom // _StringName = _NameTable.Add("String"); _MicrosoftSystemNamespace = _NameTable.Add("System"); _Decimal = _NameTable.Add("#decimal"); _Hex = _NameTable.Add("#hexidecimal"); _Amp = _NameTable.Add("amp"); _Lt = _NameTable.Add("lt"); _Gt = _NameTable.Add("gt"); _Quot = _NameTable.Add("quot"); _Apos = _NameTable.Add("apos"); _XmlNs = _NameTable.Add("xmlns"); _XmlSpaceAtom = _NameTable.Add("xml:space"); _XmlLangAtom = _NameTable.Add("xml:lang"); // //fields collection // _Used = -1; _MarkScannerCount = 10000; // _XmlSpace = XmlSpace.None; _XmlLang = String.Empty; _WhitespaceHandling = WhitespaceHandling.All; _XmlResolver = new XmlUrlResolver(); _CheckNamespaces = true; _TmpToken = new XmlNSElementTokenInfo(_Scanner, _NsMgr, XmlNodeType.None, String.Empty,-1, -1, -1, 0,false); _CurrentToken = _TmpToken; // PERF: these node types are not common therefore they // will only be constructed when used // _CommentToken = null; _CDATAToken = null; _DocTypeToken = null; _PIToken = null; _EndEntityToken = null; _NextFunction = _InitReader; _StringBuilder = new StringBuilder(100); }