-
Notifications
You must be signed in to change notification settings - Fork 3
/
PySubStream.cs
59 lines (48 loc) · 1.58 KB
/
PySubStream.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.IO;
namespace eveMarshal
{
public class PySubStream : PyObject
{
public byte[] RawData { get; set; }
public PyObject Data { get; set; }
public Unmarshal DataUnmarshal { get; set; }
public PySubStream()
: base(PyObjectType.SubStream)
{
}
public PySubStream(byte[] data)
: base(PyObjectType.SubStream)
{
RawData = data;
DataUnmarshal = new Unmarshal();
Data = DataUnmarshal.Process(data);
}
public PySubStream(PyObject data)
: base(PyObjectType.SubStream)
{
Data = data;
}
public override void Decode(Unmarshal context, MarshalOpcode op, BinaryReader source)
{
uint len = source.ReadSizeEx();
RawData = source.ReadBytes((int) len);
DataUnmarshal = new Unmarshal();
Data = DataUnmarshal.Process(RawData);
}
protected override void EncodeInternal(BinaryWriter output)
{
output.WriteOpcode(MarshalOpcode.SubStream);
var tempMs = new MemoryStream();
var temp = new BinaryWriter(tempMs);
temp.Write((byte)0x7E);
temp.Write((uint)0);
Data.Encode(temp);
output.WriteSizeEx((uint)tempMs.Length);
output.Write(tempMs.ToArray());
}
public override string ToString()
{
return "<SubStream: " + Data + ">";
}
}
}