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(); } } }