public object Read(ProtoReader reader) { IList list = (isArray ? new ArrayList() : (IList)Activator.CreateInstance(listType)); int fieldNumber; int messageSize = reader.BeginSubMessage(); while ((fieldNumber = reader.ReadTag()) > 0) { object value; if (reader.WireType == WireType.Null) { value = reader.ReadNull(); } else { value = this.typeDescription.NestedMessageSerializer.Read(reader); } list.Add(value); } reader.EndSubMessage(messageSize); if (isArray) { int length = list.Count; Array array = Array.CreateInstance(elementType, length); list.CopyTo(array, 0); return array; } return list; }
public object Read(ProtoReader reader) { int fn = reader.ReadTag(); if (fn == 0) { throw new InvalidProgramException(); } return this.itemSerializer.Read(reader); }
public object Read(ProtoReader reader) { object instance = Activator.CreateInstance(objectType); int fn; while((fn = reader.ReadTag()) > 0) { IMemberSerializer serializer = GetSerializerByFieldNumber(fn); if (serializer == null) continue; serializer.Read(reader, instance); } return instance; }