Exemplo n.º 1
0
        public void Serialize(ref MessagePackWriter writer, ReactivePropertySlim <T> value, MessagePackSerializerOptions options)
        {
            if (value == null)
            {
                writer.WriteNil();
            }
            else
            {
                writer.WriteArrayHeader(2);

                writer.Write(ReactivePropertySchedulerMapper.ToReactivePropertySlimModeInt(value));
                options.Resolver.GetFormatterWithVerify <T>().Serialize(ref writer, value.Value, options);
            }
        }
Exemplo n.º 2
0
        public int Serialize(ref byte[] bytes, int offset, ReactivePropertySlim <T> value, IFormatterResolver formatterResolver)
        {
            if (value == null)
            {
                return(MessagePackBinary.WriteNil(ref bytes, offset));
            }
            else
            {
                var startOffset = offset;

                offset += MessagePackBinary.WriteFixedArrayHeaderUnsafe(ref bytes, offset, 2);

                offset += MessagePackBinary.WriteInt32(ref bytes, offset, ReactivePropertySchedulerMapper.ToReactivePropertySlimModeInt(value));
                offset += formatterResolver.GetFormatterWithVerify <T>().Serialize(ref bytes, offset, value.Value, formatterResolver);

                return(offset - startOffset);
            }
        }