forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoolSerializer.cs
More file actions
32 lines (27 loc) · 957 Bytes
/
Copy pathBoolSerializer.cs
File metadata and controls
32 lines (27 loc) · 957 Bytes
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
// -----------------------------------------------------------------------
// <copyright file="BoolSerializer.cs" company="Asynkron HB">
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
// </copyright>
// -----------------------------------------------------------------------
using System.IO;
namespace Wire.ValueSerializers
{
public class BoolSerializer : SessionIgnorantValueSerializer<bool>
{
public const byte Manifest = 6;
public static readonly BoolSerializer Instance = new BoolSerializer();
public BoolSerializer() :
base(Manifest, () => WriteValueImpl, () => ReadValueImpl)
{
}
public static bool ReadValueImpl(Stream stream)
{
var b = stream.ReadByte();
return b != 0;
}
public static void WriteValueImpl(Stream stream, bool b)
{
stream.WriteByte((byte) (b ? 1 : 0));
}
}
}