Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        public object Read(ProtoReader reader)
        {
            if (reader.WireType == WireType.Null)
            {
                return reader.ReadNull();
            }

            object value = null;

            int messageSize = reader.BeginSubMessage();
            value = this.itemSerializer.Read(reader);
            reader.EndSubMessage(messageSize);

            return value;
        }