Ejemplo n.º 1
0
        private static T Deserialize <T>(DeserializationContext context)
        {
            var    value  = SomeObjectProto.Parser.ParseFrom(context.PayloadAsReadOnlySequence());
            object result = new Message <SomeObjectProto>(value);

            return((T)result);
        }
Ejemplo n.º 2
0
        private T Deserialize <T>(DeserializationContext context)
        {
            var jsonData = context.PayloadAsReadOnlySequence();
            var reader   = new Utf8JsonReader(jsonData);

            return(JsonSerializer.Deserialize <T>(ref reader, Options));
        }
Ejemplo n.º 3
0
        private static Message <RentedArray> Deserialize(DeserializationContext context)
        {
            var sequence = context.PayloadAsReadOnlySequence();
            var length   = context.PayloadLength;
            var source   = sequence.Slice(0, length);

            var rentedArray = RentedArray.Rent(length);

            source.CopyTo(rentedArray.Array.AsSpan(0, length));

            return(new Message <RentedArray>(rentedArray));
        }
Ejemplo n.º 4
0
 private static T DeserializeDefault <T>(DeserializationContext context)
 {
     return(RuntimeTypeModel.Default.Deserialize <T>(context.PayloadAsReadOnlySequence()));
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a readable <see cref="Stream"/> that can be used to read data from <see cref="DeserializationContext"/>.
        /// </summary>
        /// <param name="context">Deserialization context.</param>
        /// <returns>Readable <see cref="Stream"/>.</returns>
        public static Stream AsStream(this DeserializationContext context)
        {
            context.AssertNotNull(nameof(context));

            return(new BufferReaderStream(context.PayloadAsReadOnlySequence()));
        }
Ejemplo n.º 6
0
 internal static T Deserialize <T>(DeserializationContext context, MessagePackSerializerOptions options)
 {
     return(MessagePackSerializer.Deserialize <T>(context.PayloadAsReadOnlySequence(), options));
 }
Ejemplo n.º 7
0
 private static T DeserializeDefault <T>(DeserializationContext context)
 {
     return(MessagePackSerializer.Deserialize <T>(context.PayloadAsReadOnlySequence(), MessagePackSerializer.DefaultOptions));
 }
Ejemplo n.º 8
0
 internal static T Deserialize <T>(DeserializationContext context, RuntimeTypeModel runtimeTypeModel)
 {
     return(runtimeTypeModel.Deserialize <T>(context.PayloadAsReadOnlySequence()));
 }