A game about forced loneliness, made by TACStudios
1/*---------------------------------------------------------------------------------------------
2 * Copyright (c) Microsoft Corporation. All rights reserved.
3 * Licensed under the MIT License. See License.txt in the project root for license information.
4 *--------------------------------------------------------------------------------------------*/
5using System.IO;
6using System.Text;
7
8namespace Microsoft.Unity.VisualStudio.Editor.Messaging
9{
10 internal class Deserializer
11 {
12 private readonly BinaryReader _reader;
13
14 public Deserializer(byte[] buffer)
15 {
16 _reader = new BinaryReader(new MemoryStream(buffer));
17 }
18
19 public int ReadInt32()
20 {
21 return _reader.ReadInt32();
22 }
23
24 public string ReadString()
25 {
26 var length = ReadInt32();
27 return length > 0
28 ? Encoding.UTF8.GetString(_reader.ReadBytes(length))
29 : "";
30 }
31
32 public bool CanReadMore()
33 {
34 return _reader.BaseStream.Position < _reader.BaseStream.Length;
35 }
36 }
37}