private static bool TryDeserializeWithLengthPrefix <T>(SerializationContext context, PrefixStyle style, int tag, out T item) { uint len; if (!TryReadPrefixLength(context, style, tag, out len)) { item = default(T); return(false); } item = default(T); switch (len) { case 0: // nothing to do break; case uint.MaxValue: // read to end SerializerProxy <T> .Default.Deserialize(ref item, context); break; default: // limit and read sub-stream long restore = context.Limit(len); SerializerProxy <T> .Default.Deserialize(ref item, context); context.MaxReadPosition = restore; break; } return(true); }