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

◆ ReadString()

virtual string System.IO.BinaryReader.ReadString ( )
inlinevirtualinherited

Definition at line 263 of file BinaryReader.cs.

264 {
266 int num = 0;
267 int num2 = Read7BitEncodedInt();
268 if (num2 < 0)
269 {
270 throw new IOException(SR.Format(SR.IO_InvalidStringLen_Len, num2));
271 }
272 if (num2 == 0)
273 {
274 return string.Empty;
275 }
276 if (_charBytes == null)
277 {
278 _charBytes = new byte[128];
279 }
280 if (_charBuffer == null)
281 {
282 _charBuffer = new char[_maxCharsSize];
283 }
284 StringBuilder stringBuilder = null;
285 do
286 {
287 int count = ((num2 - num > 128) ? 128 : (num2 - num));
288 int num3 = _stream.Read(_charBytes, 0, count);
289 if (num3 == 0)
290 {
291 ThrowHelper.ThrowEndOfFileException();
292 }
293 int chars = _decoder.GetChars(_charBytes, 0, num3, _charBuffer, 0);
294 if (num == 0 && num3 == num2)
295 {
296 return new string(_charBuffer, 0, chars);
297 }
298 if (stringBuilder == null)
299 {
300 stringBuilder = StringBuilderCache.Acquire(Math.Min(num2, 360));
301 }
302 stringBuilder.Append(_charBuffer, 0, chars);
303 num += num3;
304 }
305 while (num < num2);
306 return StringBuilderCache.GetStringAndRelease(stringBuilder);
307 }
readonly Decoder _decoder
readonly Stream _stream
readonly int _maxCharsSize
int Read(byte[] buffer, int offset, int count)
int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
static string GetStringAndRelease(StringBuilder sb)
static StringBuilder Acquire(int capacity=16)
StringBuilder Append(char value, int repeatCount)

References System.IO.BinaryReader._charBuffer, System.IO.BinaryReader._charBytes, System.IO.BinaryReader._decoder, System.IO.BinaryReader._maxCharsSize, System.IO.BinaryReader._stream, System.Text.StringBuilderCache.Acquire(), System.Text.StringBuilder.Append(), System.chars, System.count, System.SR.Format(), System.Text.Decoder.GetChars(), System.Text.StringBuilderCache.GetStringAndRelease(), System.SR.IO_InvalidStringLen_Len, System.Math.Min(), System.IO.Stream.Read(), System.IO.BinaryReader.Read7BitEncodedInt(), System.ThrowHelper.ThrowEndOfFileException(), and System.IO.BinaryReader.ThrowIfDisposed().

Referenced by System.Security.Claims.Claim.Claim(), System.Security.Claims.ClaimsPrincipal.ClaimsPrincipal(), System.Xml.Xsl.Runtime.XmlCollation.XmlCollation(), System.Xml.XmlWriterSettings.XmlWriterSettings(), System.Resources.ResourceReader._LoadObjectV1(), System.Resources.ResourceReader._LoadObjectV2(), System.Resources.ResourceReader._ReadResources(), Terraria.NetMessage.DecompressTileBlock_Inner(), Terraria.Chat.ChatCommandId.Deserialize(), Terraria.Chat.ChatMessage.Deserialize(), Terraria.Localization.NetworkText.Deserialize(), System.ComponentModel.Design.DesigntimeLicenseContextSerializer.Deserialize(), Terraria.Localization.NetworkText.DeserializeLiteral(), Terraria.DataStructures.PlayerDeathReason.FromReader(), Terraria.MessageBuffer.GetData(), System.Security.Claims.ClaimsIdentity.Initialize(), Terraria.GameContent.Bestiary.NPCKillsTracker.Load(), Terraria.GameContent.Bestiary.NPCWasChatWithTracker.Load(), Terraria.GameContent.Bestiary.NPCWasNearPlayerTracker.Load(), Terraria.GameContent.Creative.ItemsSacrificedUnlocksTracker.Load(), Terraria.IO.WorldFile.LoadChests(), Terraria.IO.WorldFile.LoadFooter(), Terraria.IO.WorldFile.LoadHeader(), Terraria.Map.MapHelper.LoadMapVersion1(), Terraria.Map.MapHelper.LoadMapVersion2(), Terraria.IO.WorldFile.LoadNPCs(), Terraria.IO.WorldFile.LoadSigns(), System.Resources.ResourceReader.LoadString(), System.Runtime.Serialization.Formatters.Binary.BinaryParser.ReadDecimal(), System.Runtime.Serialization.Formatters.Binary.BinaryParser.ReadString(), System.Xml.Xsl.Runtime.XmlQueryDataReader.ReadStringQ(), System.Transactions.TransactionManager.Reenlist(), System.Resources.ResourceReader.TypeNameFromTypeCode(), System.Resources.ResourceReader.UseReflectionToGetType(), Terraria.GameContent.Bestiary.NPCKillsTracker.ValidateWorld(), Terraria.GameContent.Bestiary.NPCWasChatWithTracker.ValidateWorld(), Terraria.GameContent.Bestiary.NPCWasNearPlayerTracker.ValidateWorld(), and Terraria.GameContent.Creative.ItemsSacrificedUnlocksTracker.ValidateWorld().