-
Notifications
You must be signed in to change notification settings - Fork 0
/
PtRoomList.cs
42 lines (34 loc) · 1.21 KB
/
PtRoomList.cs
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
38
39
40
41
42
//Creation time:2021/9/29 11:29:46
using System;
using System.Collections;
using System.Collections.Generic;
using Protocol.Net;
namespace Development.Net.Pt
{
public class PtRoomList
{
public byte __tag__ { get; private set; }
public List<PtRoom> Rooms { get; private set; }
public PtRoomList SetRooms(List<PtRoom> value) { Rooms = value; __tag__ |= 1; return this; }
public bool HasRooms() { return (__tag__ & 1) == 1; }
public static byte[] Write(PtRoomList data)
{
using (ByteBuffer buffer = new ByteBuffer())
{
buffer.WriteByte(data.__tag__);
if (data.HasRooms()) buffer.WriteCollection(data.Rooms, element => PtRoom.Write(element));
return buffer.GetRawBytes();
}
}
public static PtRoomList Read(byte[] bytes)
{
using (ByteBuffer buffer = new ByteBuffer(bytes))
{
PtRoomList data = new PtRoomList();
data.__tag__ = buffer.ReadByte();
if (data.HasRooms()) data.Rooms = buffer.ReadCollection(retbytes => PtRoom.Read(retbytes));
return data;
}
}
}
}