public void ReadRepeated <T>(AddRepeatedItem <T> addItem, RepeatedType <T> type, PrepareForRepeatedItems prepareForRepeatedItems = null) { var read = type.ReadElement; var tag = _lastTag; if (ProtoRepeatedInfo <T> .IsPackedRepeatedField(tag)) { // packed // read repeated size var totalSize = ReadByteSize(); if (totalSize <= 0) { return; } // try call prepare to add items if (prepareForRepeatedItems != null) { var fixedSize = ProtoSizeCalc.GetFixedBaseTypeSize(type.BaseType); if (fixedSize != 0) { var count = totalSize / fixedSize; prepareForRepeatedItems(count); } } // set length limit for this message var captureLength = SetView(totalSize); // end here will return view's end while (!End) { addItem(read(this)); } RestoreView(captureLength); } else { do { addItem(read(this)); } while (ReadTagIfEquals(tag)); } }
public ProtoOutputStream(ProtoSizeCalc sizeCalc, byte[] buffer) : base(buffer) { _sizeCalc = sizeCalc; }
public ProtoOutputStream(ProtoSizeCalc sizeCalc, byte[] buffer, int index, int count) : base(buffer, index, count) { _sizeCalc = sizeCalc; }