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

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

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

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

                return(offset - startOffset);
            }
        }