-
Notifications
You must be signed in to change notification settings - Fork 3
/
PyObjectData.cs
43 lines (34 loc) · 1.16 KB
/
PyObjectData.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
using System.Data;
using System.IO;
namespace eveMarshal
{
public class PyObjectData : PyObject
{
public PyObjectData()
: base(PyObjectType.ObjectData)
{
}
public PyObjectData(string objectName, PyObject arguments)
: base(PyObjectType.ObjectData)
{
Name = objectName;
Arguments = arguments;
}
public string Name { get; set; }
public PyObject Arguments { get; set; }
public override void Decode(Unmarshal context, MarshalOpcode op, BinaryReader source)
{
var nameObject = context.ReadObject(source);
if (nameObject.Type != PyObjectType.String)
throw new DataException("Expected PyString");
Name = (nameObject as PyString).Value;
Arguments = context.ReadObject(source);
}
protected override void EncodeInternal(BinaryWriter output)
{
output.WriteOpcode(MarshalOpcode.Object);
new PyString(Name).Encode(output);
Arguments.Encode(output);
}
}
}