public XmlTagReader(XmlReader reader) { _reader = reader; _state = new TagState(FileAccess.Read); _state.Start(); }
public BinaryTagReader(Stream stream, bool autoDetectCompression) { if (stream.CanSeek && autoDetectCompression) { if (stream.IsGzipCompressed()) { _originalStream = stream; _stream = new GZipStream(_originalStream, CompressionMode.Decompress); } else if (stream.IsDeflateCompressed()) { _originalStream = stream; _stream = new DeflateStream(_originalStream, CompressionMode.Decompress); } else { _stream = stream; } } else { _stream = stream; } _state = new TagState(FileAccess.Read); _state.Start(); }
public bool Read() { switch (_readState) { case ReadState.NotInitialized: int value; value = _stream.ReadByte(); if (value != (int)TagType.Compound) { throw new InvalidDataException("Stream does not contain a NBT compound."); } _type = TagType.Compound; _readState = ReadState.Tag; _state.Start(); _state.StartTag(_type); break; case ReadState.TagEnd: case ReadState.TagType: this.SetType(_stream.ReadByte()); break; case ReadState.Tag: case ReadState.TagValue: this.MoveToNextElement(); break; case ReadState.End: _state.SetComplete(); break; default: throw new InvalidOperationException($"Unexpected read state '{_readState}'."); } return(_readState != ReadState.End); }
public override void WriteStartDocument() { _state.Start(); _writer.WriteStartDocument(true); }
public override void WriteStartDocument() { _state.Start(); }