예제 #1
0
        public ReactiveProperty <T> Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
        {
            if (reader.TryReadNil())
            {
                return(null);
            }
            else
            {
                var length = reader.ReadArrayHeader();
                if (length != 3)
                {
                    throw new InvalidOperationException("Invalid ReactiveProperty data.");
                }

                var mode = (ReactivePropertyMode)reader.ReadInt32();

                var schedulerId = reader.ReadInt32();

                IScheduler scheduler = ReactivePropertySchedulerMapper.GetScheduler(schedulerId);

                T v = options.Resolver.GetFormatterWithVerify <T>().Deserialize(ref reader, options);

                return(new ReactiveProperty <T>(scheduler, v, mode));
            }
        }
예제 #2
0
        public ReactiveProperty <T> Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
        {
            if (MessagePackBinary.IsNil(bytes, offset))
            {
                readSize = 1;
                return(null);
            }
            else
            {
                var startOffset = offset;

                var length = MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize);
                offset += readSize;
                if (length != 3)
                {
                    throw new InvalidOperationException("Invalid ReactiveProperty data.");
                }

                var mode = (ReactivePropertyMode)MessagePackBinary.ReadInt32(bytes, offset, out readSize);
                offset += readSize;

                var schedulerId = MessagePackBinary.ReadInt32(bytes, offset, out readSize);
                offset += readSize;

                var scheduler = ReactivePropertySchedulerMapper.GetScheduler(schedulerId);

                var v = formatterResolver.GetFormatterWithVerify <T>().Deserialize(bytes, offset, formatterResolver, out readSize);
                offset += readSize;

                readSize = offset - startOffset;

                return(new ReactiveProperty <T>(scheduler, v, mode));
            }
        }