summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/CharSerializer.cs
blob: f2a9867a3b38461ed6c107a8ed7100851068e23b (plain)
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
using System;
using ProtoBuf.Meta;

namespace ProtoBuf.Serializers
{
	internal sealed class CharSerializer : UInt16Serializer
	{
		public override Type ExpectedType
		{
			get
			{
				return CharSerializer.expectedType;
			}
		}

		private static readonly Type expectedType = typeof(char);

		public CharSerializer(TypeModel model) : base(model)
		{
		}

		public override void Write(object value, ProtoWriter dest)
		{
			ProtoWriter.WriteUInt16((ushort)((char)value), dest);
		}

		public override object Read(object value, ProtoReader source)
		{
			Helpers.DebugAssert(value == null);
			return (char)source.ReadUInt16();
		}
	}
}