예제 #1
0
        public T Deserialize(MessageReader reader, T target,
                             UnknownFieldCollection missing)
        {
            MessageTag tag = new MessageTag();

            while (reader.TryReadMessageTag(ref tag))
            {
                if (TryGetFieldReader(tag))
                {
                    if (tag.WireType == WireType.String)
                    {
                        _current.Value(target, reader.CreateSubReader());
                    }

                    else
                    {
                        try
                        {
                            _current.Value(target, reader);
                        }
                        catch (UnknownEnumException e)
                        {
                            missing.Add(new UnknownFieldVarint(tag, e.Value));
                        }
                    }
                }
                else if (tag.WireType == WireType.EndGroup)
                {
                    break;
                }

                else if (tag.WireType < WireType.MaxValid)
                {
                    missing.Add(tag, reader);
                }

                else
                {
                    throw new NotSupportedException();
                }
            }
            return(target);
        }
예제 #2
0
 public static T Deserialize <T>(MessageReader reader, UnknownFieldCollection missing)
     where T : new()
 {
     return(new Serializer <T>().Deserialize(reader, new T(), missing));
 }
예제 #3
0
 public static T Deserialize <T>(Stream stream, UnknownFieldCollection missing)
     where T : new()
 {
     return(Deserialize <T>(new MessageReader(stream), missing));
 }