0002-Implement-the-default-converters.patch
rsb-cil-test/Program.cs | ||
---|---|---|
79 | 79 | |
80 | 80 |
listener.Deactivate(); |
81 | 81 | |
82 |
} |
|
82 |
Console.WriteLine("\nConverter test:"); |
|
83 | ||
84 |
var defaultInConverters = buildConverterSelection(new List<Tuple<String, IConverter>> { |
|
85 |
new Tuple<string, IConverter>("ascii-string", new StringConverter(false) ), |
|
86 |
new Tuple<string, IConverter>("utf-8-string", new StringConverter(true) ), |
|
87 |
new Tuple<string, IConverter>("int32", new Int32Converter() ), |
|
88 |
new Tuple<string, IConverter>("int64", new Int64Converter() ), |
|
89 |
new Tuple<string, IConverter>("uint32", new UInt32Converter() ), |
|
90 |
new Tuple<string, IConverter>("uint64", new UInt64Converter() ), |
|
91 |
new Tuple<string, IConverter>("float", new FloatConverter() ), |
|
92 |
new Tuple<string, IConverter>("double", new DoubleConverter() ), |
|
93 |
new Tuple<string, IConverter>("bool", new BoolConverter() ), |
|
94 |
new Tuple<string, IConverter>("bytes", new ByteConverter() ), |
|
95 |
new Tuple<string, IConverter>("void", new NullConverter() ), |
|
96 |
new Tuple<string, IConverter>("." + JointAngles.Descriptor.FullName, new ProtocolBufferConverter(JointAngles.Descriptor)) |
|
97 |
}); |
|
98 | ||
99 |
var defaultOutConverters = buildConverterSelection(new List<Tuple<Type, IConverter>> { |
|
100 |
new Tuple<Type, IConverter>(typeof(string), new StringConverter(true) ), |
|
101 |
new Tuple<Type, IConverter>(typeof(int), new Int32Converter() ), |
|
102 |
new Tuple<Type, IConverter>(typeof(long), new Int64Converter() ), |
|
103 |
new Tuple<Type, IConverter>(typeof(uint), new UInt32Converter() ), |
|
104 |
new Tuple<Type, IConverter>(typeof(ulong), new UInt64Converter() ), |
|
105 |
new Tuple<Type, IConverter>(typeof(float), new FloatConverter() ), |
|
106 |
new Tuple<Type, IConverter>(typeof(double), new DoubleConverter() ), |
|
107 |
new Tuple<Type, IConverter>(typeof(bool), new BoolConverter() ), |
|
108 |
new Tuple<Type, IConverter>(typeof(byte[]), new ByteConverter() ), |
|
109 |
new Tuple<Type, IConverter>(typeof(Null), new NullConverter() ), |
|
110 |
new Tuple<Type, IConverter>(typeof(JointAngles), new ProtocolBufferConverter(JointAngles.Descriptor)) |
|
111 |
}); |
|
112 | ||
113 |
Informer repoInformer = new Informer("/test/repo", new OutConnector(new BusClientConnection(host, port), defaultOutConverters)); |
|
114 |
Listener repoListener = new Listener(new InPushConnector(new BusClientConnection(host, port), new Scope("/"), defaultInConverters)); |
|
115 |
repoListener.EventReceived += (e) => { |
|
116 |
Console.WriteLine("Event: {0}\nData: {1}", e, e.Data); |
|
117 |
}; |
|
118 |
repoListener.Activate(); |
|
119 |
repoInformer.Activate(); |
|
120 | ||
121 |
//test string |
|
122 |
repoInformer.Send("Teest"); |
|
123 |
//test bool |
|
124 |
repoInformer.Send(true); |
|
125 |
//test int |
|
126 |
repoInformer.Send(42); |
|
127 |
//test long (int64 |
|
128 |
repoInformer.Send((long)42); |
|
129 |
//test for uint32 |
|
130 |
repoInformer.Send((uint)4242); |
|
131 |
//test for uint64 |
|
132 |
repoInformer.Send((ulong)4242); |
|
133 |
//test double |
|
134 |
repoInformer.Send(4.2); |
|
135 |
//test float |
|
136 |
repoInformer.Send((float)4.2); |
|
137 |
//test byte[] |
|
138 |
byte[] test = { 12, 13, 14, 255 }; |
|
139 |
repoInformer.Send(test); |
|
140 |
//test void |
|
141 |
repoInformer.Send(Null.Instance); |
|
142 |
// protobuf type |
|
143 |
var jointAngles = new JointAngles(); |
|
144 |
for (int i = 0; i < 5; i++) |
|
145 |
{ |
|
146 |
jointAngles.Angles.Add(i); |
|
147 |
repoInformer.Send(jointAngles); |
|
148 |
} |
|
149 | ||
150 |
repoInformer.Deactivate(); |
|
151 |
Console.ReadKey(); |
|
152 |
repoListener.Deactivate(); |
|
153 |
} |
|
83 | 154 | |
84 | 155 |
} |
85 | 156 |
} |
rsb-cil/Rsb/Converter/BoolConverter.cs | ||
---|---|---|
4 | 4 |
public class BoolConverter: IConverter |
5 | 5 |
{ |
6 | 6 | |
7 |
private static readonly string WIRE_SCHEMA = "bool";
|
|
7 |
private static readonly ConverterSignature SIGNATURE = new ConverterSignature("bool", typeof(bool));
|
|
8 | 8 | |
9 | 9 |
public object Deserialize(Tuple<string, byte[]> data) |
10 | 10 |
{ |
11 |
if (data.Item1 != WIRE_SCHEMA)
|
|
11 |
if (data.Item1 != SIGNATURE.Schema)
|
|
12 | 12 |
{ |
13 | 13 |
throw new ConversionException("Unexpected wire schema for deserialization: " + data.Item1); |
14 | 14 |
} |
... | ... | |
19 | 19 |
return data.Item2[0] != 0; |
20 | 20 |
} |
21 | 21 | |
22 |
public Tuple<string, byte[]> Serialize(object data) |
|
22 |
public ConverterSignature GetSignature() |
|
23 |
{ |
|
24 |
return SIGNATURE; |
|
25 |
} |
|
26 | ||
27 |
public Tuple<string, byte[]> Serialize(object data) |
|
23 | 28 |
{ |
24 |
return new Tuple<string, byte[]>(WIRE_SCHEMA, ((bool)data) ? new byte[] { 1 } : new byte[] { 0 });
|
|
29 |
return new Tuple<string, byte[]>(SIGNATURE.Schema, ((bool)data) ? new byte[] { 1 } : new byte[] { 0 });
|
|
25 | 30 |
} |
26 | 31 | |
32 | ||
27 | 33 |
} |
28 | 34 |
} |
rsb-cil/Rsb/Converter/ByteConverter.cs | ||
---|---|---|
1 |
using System; |
|
2 | ||
3 |
namespace Rsb.Converter |
|
4 |
{ |
|
5 |
public class ByteConverter : IConverter |
|
6 |
{ |
|
7 |
private static readonly ConverterSignature SIGNATURE = new ConverterSignature("bytes", typeof(byte[])); |
|
8 |
|
|
9 |
public object Deserialize(Tuple<string, byte[]> data) |
|
10 |
{ |
|
11 |
if (data.Item1 != SIGNATURE.Schema) |
|
12 |
{ |
|
13 |
throw new ConversionException("Unexpected wire schema for deserialization: " + data.Item1); |
|
14 |
} |
|
15 |
return data.Item2; |
|
16 |
} |
|
17 | ||
18 |
public ConverterSignature GetSignature() |
|
19 |
{ |
|
20 |
return SIGNATURE; |
|
21 |
} |
|
22 | ||
23 |
public Tuple<string, byte[]> Serialize(object data) |
|
24 |
{ |
|
25 |
return new Tuple<string, byte[]>(SIGNATURE.Schema, (byte[]) data); |
|
26 |
} |
|
27 |
} |
|
28 |
} |
rsb-cil/Rsb/Converter/ConverterSignature.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 | ||
7 |
namespace Rsb.Converter |
|
8 |
{ |
|
9 |
public class ConverterSignature |
|
10 |
{ |
|
11 |
private String schema; |
|
12 |
private Type dataType; |
|
13 | ||
14 |
public String Schema { get => schema; } |
|
15 |
public Type DataType { get => dataType; } |
|
16 | ||
17 |
public ConverterSignature(String schema, Type dataType) |
|
18 |
{ |
|
19 |
this.schema = schema; |
|
20 |
this.dataType = dataType; |
|
21 |
} |
|
22 | ||
23 |
public override int GetHashCode() |
|
24 |
{ |
|
25 |
int prime = 31; |
|
26 |
int result = 1; |
|
27 |
result = prime * result + this.dataType.GetHashCode(); |
|
28 |
result = prime * result + this.schema.GetHashCode(); |
|
29 |
return result; |
|
30 |
} |
|
31 | ||
32 |
public override bool Equals(Object obj) |
|
33 |
{ |
|
34 |
if (this == obj) |
|
35 |
{ |
|
36 |
return true; |
|
37 |
} |
|
38 |
if (obj == null) |
|
39 |
{ |
|
40 |
return false; |
|
41 |
} |
|
42 |
ConverterSignature rhs = obj as ConverterSignature; |
|
43 |
if (rhs == null) { |
|
44 |
return false; |
|
45 |
} |
|
46 |
if (!this.dataType.Equals(rhs.dataType)) |
|
47 |
{ |
|
48 |
return false; |
|
49 |
} |
|
50 |
if (!this.schema.Equals(rhs.schema)) |
|
51 |
{ |
|
52 |
return false; |
|
53 |
} |
|
54 |
return true; |
|
55 |
} |
|
56 | ||
57 |
public override String ToString() |
|
58 |
{ |
|
59 |
return "ConverterSignature [schema=" + this.schema + ", datatype=" |
|
60 |
+ this.dataType + "]"; |
|
61 |
} |
|
62 |
} |
|
63 |
} |
rsb-cil/Rsb/Converter/DoubleConverter.cs | ||
---|---|---|
1 |
using System; |
|
2 | ||
3 |
namespace Rsb.Converter |
|
4 |
{ |
|
5 |
public class DoubleConverter : IConverter |
|
6 |
{ |
|
7 |
private static readonly ConverterSignature SIGNATURE = new ConverterSignature("double", typeof(double)); |
|
8 | ||
9 |
public object Deserialize(Tuple<string, byte[]> data) |
|
10 |
{ |
|
11 |
if (data.Item1 != SIGNATURE.Schema) |
|
12 |
{ |
|
13 |
throw new ConversionException("Unexpected wire schema for deserialization: " + data.Item1); |
|
14 |
} |
|
15 |
if (data.Item2.Length != 8) |
|
16 |
{ |
|
17 |
throw new ConversionException("Data of type double must have length 8. Received: " + data.Item2.Length); |
|
18 |
} |
|
19 |
return BitConverter.ToDouble(data.Item2, 0); |
|
20 |
} |
|
21 | ||
22 |
public ConverterSignature GetSignature() |
|
23 |
{ |
|
24 |
return SIGNATURE; |
|
25 |
} |
|
26 | ||
27 |
public Tuple<string, byte[]> Serialize(object data) |
|
28 |
{ |
|
29 |
return new Tuple<string, byte[]>(SIGNATURE.Schema, BitConverter.GetBytes((double)data)); |
|
30 |
} |
|
31 |
} |
|
32 |
} |
rsb-cil/Rsb/Converter/FloatConverter.cs | ||
---|---|---|
1 |
using System; |
|
2 | ||
3 |
namespace Rsb.Converter |
|
4 |
{ |
|
5 |
public class FloatConverter : IConverter |
|
6 |
{ |
|
7 |
private static readonly ConverterSignature SIGNATURE = new ConverterSignature("float", typeof(float)); |
|
8 | ||
9 |
public object Deserialize(Tuple<string, byte[]> data) |
|
10 |
{ |
|
11 |
if (data.Item1 != SIGNATURE.Schema) |
|
12 |
{ |
|
13 |
throw new ConversionException("Unexpected wire schema for deserialization: " + data.Item1); |
|
14 |
} |
|
15 |
if (data.Item2.Length != 4) |
|
16 |
{ |
|
17 |
throw new ConversionException("Data of type float must have length 4. Received: " + data.Item2.Length); |
|
18 |
} |
|
19 |
return BitConverter.ToSingle(data.Item2, 0); |
|
20 |
} |
|
21 | ||
22 |
public ConverterSignature GetSignature() |
|
23 |
{ |
|
24 |
return SIGNATURE; |
|
25 |
} |
|
26 | ||
27 |
public Tuple<string, byte[]> Serialize(object data) |
|
28 |
{ |
|
29 |
return new Tuple<string, byte[]>(SIGNATURE.Schema, BitConverter.GetBytes((float)data)); |
|
30 |
} |
|
31 |
} |
|
32 |
} |
rsb-cil/Rsb/Converter/IConverter.cs | ||
---|---|---|
8 | 8 | |
9 | 9 |
object Deserialize(Tuple<string, byte[]> data); |
10 | 10 | |
11 |
ConverterSignature GetSignature(); |
|
12 | ||
11 | 13 |
} |
12 | 14 |
} |
rsb-cil/Rsb/Converter/Int32Converter.cs | ||
---|---|---|
1 |
using System; |
|
2 | ||
3 |
namespace Rsb.Converter |
|
4 |
{ |
|
5 |
public class Int32Converter : IConverter |
|
6 |
{ |
|
7 |
private static readonly ConverterSignature SIGNATURE = new ConverterSignature("int32", typeof(int)); |
|
8 | ||
9 |
public object Deserialize(Tuple<string, byte[]> data) |
|
10 |
{ |
|
11 |
if (data.Item1 != SIGNATURE.Schema) |
|
12 |
{ |
|
13 |
throw new ConversionException("Unexpected wire schema for deserialization: " + data.Item1); |
|
14 |
} |
|
15 |
if (data.Item2.Length != 4) |
|
16 |
{ |
|
17 |
throw new ConversionException("Data of type int32 must have length 4. Received: " + data.Item2.Length); |
|
18 |
} |
|
19 |
return BitConverter.ToInt32(data.Item2,0); |
|
20 |
} |
|
21 | ||
22 |
public ConverterSignature GetSignature() |
|
23 |
{ |
|
24 |
return SIGNATURE; |
|
25 |
} |
|
26 | ||
27 |
public Tuple<string, byte[]> Serialize(object data) |
|
28 |
{ |
|
29 |
return new Tuple<string, byte[]>(SIGNATURE.Schema, BitConverter.GetBytes((int) data)); |
|
30 |
} |
|
31 |
} |
|
32 |
} |
rsb-cil/Rsb/Converter/Int64Converter.cs | ||
---|---|---|
1 |
using System; |
|
2 | ||
3 |
namespace Rsb.Converter |
|
4 |
{ |
|
5 |
public class Int64Converter : IConverter |
|
6 |
{ |
|
7 |
private static readonly ConverterSignature SIGNATURE = new ConverterSignature("int64", typeof(long)); |
|
8 | ||
9 |
public object Deserialize(Tuple<string, byte[]> data) |
|
10 |
{ |
|
11 |
if (data.Item1 != SIGNATURE.Schema) |
|
12 |
{ |
|
13 |
throw new ConversionException("Unexpected wire schema for deserialization: " + data.Item1); |
|
14 |
} |
|
15 |
if (data.Item2.Length != 8) |
|
16 |
{ |
|
17 |
throw new ConversionException("Data of type int64 must have length 8. Received: " + data.Item2.Length); |
|
18 |
} |
|
19 |
return BitConverter.ToInt64(data.Item2, 0); |
|
20 |
} |
|
21 | ||
22 |
public ConverterSignature GetSignature() |
|
23 |
{ |
|
24 |
return SIGNATURE; |
|
25 |
} |
|
26 | ||
27 |
public Tuple<string, byte[]> Serialize(object data) |
|
28 |
{ |
|
29 |
return new Tuple<string, byte[]>(SIGNATURE.Schema, BitConverter.GetBytes((long)data)); |
|
30 |
} |
|
31 |
} |
|
32 |
} |
rsb-cil/Rsb/Converter/NullConverter.cs | ||
---|---|---|
1 |
using System; |
|
2 | ||
3 |
namespace Rsb.Converter |
|
4 |
{ |
|
5 |
public class NullConverter : IConverter |
|
6 |
{ |
|
7 |
private static readonly ConverterSignature SIGNATURE = new ConverterSignature("void", typeof(Null)); |
|
8 | ||
9 |
public object Deserialize(Tuple<string, byte[]> data) |
|
10 |
{ |
|
11 |
if (data.Item1 != SIGNATURE.Schema) |
|
12 |
{ |
|
13 |
throw new ConversionException("Unexpected wire schema for deserialization: " + data.Item1); |
|
14 |
} |
|
15 |
return null; |
|
16 |
} |
|
17 | ||
18 |
public ConverterSignature GetSignature() |
|
19 |
{ |
|
20 |
return SIGNATURE; |
|
21 |
} |
|
22 | ||
23 |
public Tuple<string, byte[]> Serialize(object data) |
|
24 |
{ |
|
25 |
return new Tuple<string, byte[]>(SIGNATURE.Schema, new byte[0]); |
|
26 |
} |
|
27 |
} |
|
28 | ||
29 |
public sealed class Null { |
|
30 |
private static readonly Null instance = new Null(); |
|
31 | ||
32 |
// Explicit static constructor to tell C# compiler |
|
33 |
// not to mark type as beforefieldinit |
|
34 |
static Null() |
|
35 |
{ |
|
36 |
} |
|
37 | ||
38 |
private Null() |
|
39 |
{ |
|
40 |
} |
|
41 | ||
42 |
public static Null Instance |
|
43 |
{ |
|
44 |
get |
|
45 |
{ |
|
46 |
return instance; |
|
47 |
} |
|
48 |
} |
|
49 |
} |
|
50 | ||
51 |
} |
rsb-cil/Rsb/Converter/ProtocolBufferConverter.cs | ||
---|---|---|
3 | 3 |
using Google.Protobuf.Reflection; |
4 | 4 |
namespace Rsb.Converter |
5 | 5 |
{ |
6 |
public class ProtocolBufferConverter: IConverter |
|
7 |
{ |
|
6 |
public class ProtocolBufferConverter : IConverter |
|
7 |
{ |
|
8 |
private ConverterSignature SIGNATURE; |
|
8 | 9 | |
9 |
private MessageDescriptor descriptor;
|
|
10 |
private string wireSchema; |
|
11 | ||
12 |
public ProtocolBufferConverter(MessageDescriptor descriptor) |
|
13 |
{ |
|
14 |
this.wireSchema = "." + descriptor.FullName; |
|
15 |
this.descriptor = descriptor;
|
|
16 |
}
|
|
10 |
private MessageDescriptor descriptor;
|
|
11 |
|
|
12 |
public ProtocolBufferConverter(MessageDescriptor descriptor) |
|
13 |
{ |
|
14 |
SIGNATURE = new ConverterSignature("." + descriptor.FullName, descriptor.ClrType); |
|
15 |
|
|
16 |
this.descriptor = descriptor;
|
|
17 |
}
|
|
17 | 18 | |
18 | 19 |
public object Deserialize(Tuple<string, byte[]> data) |
19 | 20 |
{ |
20 |
if (data.Item1 != this.wireSchema)
|
|
21 |
if (data.Item1 != SIGNATURE.Schema)
|
|
21 | 22 |
{ |
22 |
throw new ConversionException("Cannot deserialize data of type " + data.Item1 + ". Expecting " + wireSchema);
|
|
23 |
throw new ConversionException("Cannot deserialize data of type " + data.Item1 + ". Expecting " + SIGNATURE.Schema);
|
|
23 | 24 |
} |
24 | 25 | |
25 | 26 |
return this.descriptor.Parser.ParseFrom(data.Item2); |
... | ... | |
28 | 29 |
public Tuple<string, byte[]> Serialize(object data) |
29 | 30 |
{ |
30 | 31 |
IMessage message = (Google.Protobuf.IMessage)data; |
31 |
return new Tuple<string, byte[]>(this.wireSchema, message.ToByteArray());
|
|
32 |
return new Tuple<string, byte[]>(SIGNATURE.Schema, message.ToByteArray());
|
|
32 | 33 |
} |
33 |
} |
|
34 | ||
35 |
public ConverterSignature GetSignature() |
|
36 |
{ |
|
37 |
return SIGNATURE; |
|
38 |
} |
|
39 |
} |
|
34 | 40 |
} |
rsb-cil/Rsb/Converter/StringConverter.cs | ||
---|---|---|
1 |
using System; |
|
2 | ||
3 |
namespace Rsb.Converter |
|
4 |
{ |
|
5 |
public class StringConverter : IConverter |
|
6 |
{ |
|
7 |
|
|
8 |
private System.Text.Encoding Encoding; |
|
9 |
|
|
10 |
private ConverterSignature SIGNATURE; |
|
11 |
|
|
12 |
public StringConverter(bool utf8 = true) { |
|
13 |
if (utf8) |
|
14 |
{ |
|
15 |
Encoding = new System.Text.UTF8Encoding(); |
|
16 |
SIGNATURE = new ConverterSignature("utf-8-string", typeof(string)); |
|
17 |
} |
|
18 |
else { |
|
19 |
Encoding = new System.Text.ASCIIEncoding(); |
|
20 |
SIGNATURE = new ConverterSignature("ascii-string", typeof(string)); |
|
21 |
} |
|
22 |
} |
|
23 | ||
24 |
public object Deserialize(Tuple<string, byte[]> data) |
|
25 |
{ |
|
26 |
if (data.Item1 != SIGNATURE.Schema) |
|
27 |
{ |
|
28 |
throw new ConversionException("Unexpected wire schema for deserialization: " + data.Item1); |
|
29 |
} |
|
30 |
return Encoding.GetString(data.Item2); |
|
31 |
} |
|
32 | ||
33 |
public Tuple<string, byte[]> Serialize(object data) |
|
34 |
{ |
|
35 |
return new Tuple<string, byte[]>(SIGNATURE.Schema, Encoding.GetBytes(data.ToString())); |
|
36 |
} |
|
37 | ||
38 |
public ConverterSignature GetSignature() |
|
39 |
{ |
|
40 |
return SIGNATURE; |
|
41 |
} |
|
42 |
} |
|
43 |
} |
rsb-cil/Rsb/Converter/UInt32Converter.cs | ||
---|---|---|
1 |
using System; |
|
2 | ||
3 |
namespace Rsb.Converter |
|
4 |
{ |
|
5 |
public class UInt32Converter : IConverter |
|
6 |
{ |
|
7 |
private static readonly ConverterSignature SIGNATURE = new ConverterSignature("uint32", typeof(uint)); |
|
8 | ||
9 |
public object Deserialize(Tuple<string, byte[]> data) |
|
10 |
{ |
|
11 |
if (data.Item1 != SIGNATURE.Schema) |
|
12 |
{ |
|
13 |
throw new ConversionException("Unexpected wire schema for deserialization: " + data.Item1); |
|
14 |
} |
|
15 |
if (data.Item2.Length != 4) |
|
16 |
{ |
|
17 |
throw new ConversionException("Data of type uint32 must have length 4. Received: " + data.Item2.Length); |
|
18 |
} |
|
19 |
return BitConverter.ToUInt32(data.Item2, 0); |
|
20 |
} |
|
21 | ||
22 |
public ConverterSignature GetSignature() |
|
23 |
{ |
|
24 |
return SIGNATURE; |
|
25 |
} |
|
26 | ||
27 |
public Tuple<string, byte[]> Serialize(object data) |
|
28 |
{ |
|
29 |
return new Tuple<string, byte[]>(SIGNATURE.Schema, BitConverter.GetBytes((uint)data)); |
|
30 |
} |
|
31 |
} |
|
32 |
} |
rsb-cil/Rsb/Converter/UInt64Converter.cs | ||
---|---|---|
1 |
using System; |
|
2 | ||
3 |
namespace Rsb.Converter |
|
4 |
{ |
|
5 |
public class UInt64Converter : IConverter |
|
6 |
{ |
|
7 |
private static readonly ConverterSignature SIGNATURE = new ConverterSignature("uint64", typeof(ulong)); |
|
8 | ||
9 |
public object Deserialize(Tuple<string, byte[]> data) |
|
10 |
{ |
|
11 |
if (data.Item1 != SIGNATURE.Schema) |
|
12 |
{ |
|
13 |
throw new ConversionException("Unexpected wire schema for deserialization: " + data.Item1); |
|
14 |
} |
|
15 |
if (data.Item2.Length != 8) |
|
16 |
{ |
|
17 |
throw new ConversionException("Data of type uint64 must have length 8. Received: " + data.Item2.Length); |
|
18 |
} |
|
19 |
return BitConverter.ToUInt64(data.Item2, 0); |
|
20 |
} |
|
21 | ||
22 |
public ConverterSignature GetSignature() |
|
23 |
{ |
|
24 |
return SIGNATURE; |
|
25 |
} |
|
26 | ||
27 |
public Tuple<string, byte[]> Serialize(object data) |
|
28 |
{ |
|
29 |
return new Tuple<string, byte[]>(SIGNATURE.Schema, BitConverter.GetBytes((ulong)data)); |
|
30 |
} |
|
31 |
} |
|
32 |
} |
rsb-cil/rsb-cil.csproj | ||
---|---|---|
40 | 40 |
</ItemGroup> |
41 | 41 |
<ItemGroup> |
42 | 42 |
<Compile Include="Properties\AssemblyInfo.cs" /> |
43 |
<Compile Include="Rsb\Converter\ByteConverter.cs" /> |
|
44 |
<Compile Include="Rsb\Converter\ConverterSignature.cs" /> |
|
45 |
<Compile Include="Rsb\Converter\DoubleConverter.cs" /> |
|
46 |
<Compile Include="Rsb\Converter\FloatConverter.cs" /> |
|
47 |
<Compile Include="Rsb\Converter\Int32Converter.cs" /> |
|
48 |
<Compile Include="Rsb\Converter\Int64Converter.cs" /> |
|
49 |
<Compile Include="Rsb\Converter\NullConverter.cs" /> |
|
50 |
<Compile Include="Rsb\Converter\StringConverter.cs" /> |
|
51 |
<Compile Include="Rsb\Converter\UInt32Converter.cs" /> |
|
52 |
<Compile Include="Rsb\Converter\UInt64Converter.cs" /> |
|
43 | 53 |
<Compile Include="Rsb\Protocol\EventId.cs" /> |
44 | 54 |
<Compile Include="Rsb\Protocol\EventMetaData.cs" /> |
45 | 55 |
<Compile Include="Rsb\Protocol\Notification.cs" /> |
46 |
- |