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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
using System;
namespace MessagePack
{
public struct Nil : IEquatable<Nil>
{
public static readonly Nil Default = new Nil();
public override bool Equals(object obj)
{
return obj is Nil;
}
public bool Equals(Nil other)
{
return true;
}
public override int GetHashCode()
{
return 0;
}
public override string ToString()
{
return "()";
}
}
}
namespace MessagePack.Formatters
{
public class NilFormatter : IMessagePackFormatter<Nil>
{
public static readonly IMessagePackFormatter<Nil> Instance = new NilFormatter();
NilFormatter()
{
}
public void Serialize(IBufferWriter<byte> writer, Nil value, IFormatterResolver typeResolver)
{
return MessagePackBinary.WriteNil(ref bytes, offset);
}
public Nil Deserialize(byte[] bytes, int offset, IFormatterResolver typeResolver, out int readSize)
{
return MessagePackBinary.ReadNil(bytes, offset, out readSize);
}
}
// NullableNil is same as Nil.
public class NullableNilFormatter : IMessagePackFormatter<Nil?>
{
public static readonly IMessagePackFormatter<Nil?> Instance = new NullableNilFormatter();
NullableNilFormatter()
{
}
public void Serialize(IBufferWriter<byte> writer, Nil? value, IFormatterResolver typeResolver)
{
return MessagePackBinary.WriteNil(ref bytes, offset);
}
public Nil? Deserialize(byte[] bytes, int offset, IFormatterResolver typeResolver, out int readSize)
{
return MessagePackBinary.ReadNil(bytes, offset, out readSize);
}
}
}
|