private TList DeserializeImpl(TSource source, SerializationContext context, bool canSetValue) { TList list = GetValue(source); bool set = list == null; if (set) { list = ObjectFactory <TList> .Create(); } long restore = context.LimitByLengthPrefix(); while (context.Position < context.MaxReadPosition) { add(list, innerProperty.DeserializeImpl(default(TValue), context)); } // restore the max-pos context.MaxReadPosition = restore; if (set && canSetValue) { SetValue(source, list); } return(list); }
public override TValue[] DeserializeImpl(TSource source, SerializationContext context) { TValue[] arr = GetValue(source); TValue value = innerProperty.DeserializeImpl(default(TValue), context); if (context.TryPeekFieldPrefix(FieldPrefix)) { List <TValue> list = new List <TValue>(); list.Add(value); do { list.Add(innerProperty.DeserializeImpl(default(TValue), context)); } while (context.TryPeekFieldPrefix(FieldPrefix)); int index = Resize(ref arr, list.Count); list.CopyTo(arr, index); } else { Resize(ref arr, 1); arr[arr.Length - 1] = value; } return(arr); }
private TList DeserializeImpl(TSource source, SerializationContext context, bool canSetValue) { TList list = GetValue(source); bool set = list == null; if (set) { list = ObjectFactory <TList> .Create(); } do { add(list, innerProperty.DeserializeImpl(default(TValue), context)); } while (context.TryPeekFieldPrefix(FieldPrefix)); if (set && canSetValue) { SetValue(source, list); } return(list); }
public override TValue[] DeserializeImpl(TSource source, SerializationContext context) { TValue[] arr = GetValue(source); long restore = context.LimitByLengthPrefix(); List <TValue> list = new List <TValue>(); while (context.Position < context.MaxReadPosition) { list.Add(innerProperty.DeserializeImpl(default(TValue), context)); } // restore the max-pos context.MaxReadPosition = restore; int index = Resize(ref arr, list.Count); list.CopyTo(arr, index); return(arr); }
public override KeyValuePair <TKey, TValue> DeserializeImpl(TSource source, SerializationContext context) { TKey key = default(TKey); TValue value = default(TValue); long restore = context.LimitByLengthPrefix(); uint field; while (context.TryReadFieldPrefix(out field)) { if (field == keyProp.FieldPrefix) { key = keyProp.DeserializeImpl(key, context); } else if (field == valueProp.FieldPrefix) { value = valueProp.DeserializeImpl(value, context); } else { WireType wireType; int tag; Serializer.ParseFieldToken(field, out wireType, out tag); switch (tag) { case TAG_KEY: case TAG_VALUE: throw new ProtoException("Incorrect wire-type reading key/value pair"); } Serializer.SkipData(context, tag, wireType); } } // restore the max-pos context.MaxReadPosition = restore; return(new KeyValuePair <TKey, TValue>(key, value)); }
public override TValue DeserializeImpl(TSource source, SerializationContext context) { string value = innerSerializer.DeserializeImpl(null, context); return(value == null ? DefaultValue : parse(value)); }
public override Uri DeserializeImpl(TSource source, SerializationContext context) { string value = innerSerializer.DeserializeImpl(null, context); return(string.IsNullOrEmpty(value) ? null : new Uri(value)); }
public override TValue DeserializeImpl(TSource source, SerializationContext context) { return(inner.DeserializeImpl(GetValue(source), context)); }