Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Read() [1/5]

virtual int System.IO.BinaryReader.Read ( )
inlinevirtualinherited

Definition at line 112 of file BinaryReader.cs.

113 {
115 int num = 0;
116 long num2 = 0L;
117 if (_stream.CanSeek)
118 {
119 num2 = _stream.Position;
120 }
121 if (_charBytes == null)
122 {
123 _charBytes = new byte[128];
124 }
125 Span<char> chars = stackalloc char[1];
126 while (num == 0)
127 {
128 int num3 = ((!_2BytesPerChar) ? 1 : 2);
129 int num4 = _stream.ReadByte();
130 _charBytes[0] = (byte)num4;
131 if (num4 == -1)
132 {
133 num3 = 0;
134 }
135 if (num3 == 2)
136 {
137 num4 = _stream.ReadByte();
138 _charBytes[1] = (byte)num4;
139 if (num4 == -1)
140 {
141 num3 = 1;
142 }
143 }
144 if (num3 == 0)
145 {
146 return -1;
147 }
148 try
149 {
150 num = _decoder.GetChars(new ReadOnlySpan<byte>(_charBytes, 0, num3), chars, flush: false);
151 }
152 catch
153 {
154 if (_stream.CanSeek)
155 {
156 _stream.Seek(num2 - _stream.Position, SeekOrigin.Current);
157 }
158 throw;
159 }
160 }
161 return chars[0];
162 }
readonly Decoder _decoder
readonly Stream _stream
readonly bool _2BytesPerChar
virtual int ReadByte()
Definition Stream.cs:994
long Seek(long offset, SeekOrigin origin)
int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)

References System.IO.BinaryReader._2BytesPerChar, System.IO.BinaryReader._charBytes, System.IO.BinaryReader._decoder, System.IO.BinaryReader._stream, System.IO.Stream.CanSeek, System.chars, System.Text.Decoder.GetChars(), System.L, System.IO.Stream.Position, System.IO.Stream.ReadByte(), System.IO.Stream.Seek(), and System.IO.BinaryReader.ThrowIfDisposed().

Referenced by System.Resources.ResourceReader.AllocateStringForNameIndex(), System.Resources.ResourceReader.CompareStringEqualsName(), System.IO.BinaryReader.PeekChar(), System.Runtime.Serialization.Formatters.Binary.BinaryParser.ReadBytes(), and System.IO.BinaryReader.ReadChar().