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