public void ApplyPatch(PriceLevel patch) { if (patch.Size == 0) { _book.Remove(patch.Price); } else { _book[patch.Price] = patch.Size; } }
protected override PriceLevel[] Decode(BinaryReader reader, bool isPrimary) { // It so happens that decoding in our examle doesn't depend on isPrimary, but it could. // There is a guarantee that the decoder always sees the same value of isPrimary as what // the encoder saw when it produced the record. var res = new PriceLevel[reader.ReadInt32()]; for (int i = 0; i != res.Length; ++i) { res[i] = new PriceLevel(price: reader.ReadDecimal(), size: reader.ReadDecimal()); } return(res); }