Пример #1
0
 public void ApplyPatch(PriceLevel patch)
 {
     if (patch.Size == 0)
     {
         _book.Remove(patch.Price);
     }
     else
     {
         _book[patch.Price] = patch.Size;
     }
 }
Пример #2
0
        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);
        }