Пример #1
0
        private void _Subscire_ReceiveReady(object sender, NetMQSocketEventArgs e)
        {
            var msg = subscriber.ReceiveMultipartMessage();

            if (msg.FrameCount == 0)
            {
                return;
            }
            MarketData data = MarketData.Parser.ParseFrom(msg.Pop().ToByteArray());

            var type = data.Type;

            if (type == MarketData.Types.Type.Stock)
            {
                OnStockQuoteUpdated?.Invoke(Transfer(data.StockData));
            }
            else if (type == MarketData.Types.Type.Transaction)
            {
                OnTransactionUpdated?.Invoke(Transfer(data.TransactionData));
            }
            else if (type == MarketData.Types.Type.Order)
            {
                OnOrderUpdated?.Invoke(Transfer(data.OrderData));
            }
            else if (type == MarketData.Types.Type.Queue)
            {
                OnOrderQueueUpdated?.Invoke(Transfer(data.QueueData));
            }
        }
Пример #2
0
    public void MoveSlot(InventorySlot slot, int moveBy)
    {
        int oldIndex = items.IndexOf(slot);

        items.Remove(slot);

        int newIndex = oldIndex + moveBy;

        // clamp newIndex between 0 and items.Count
        newIndex = newIndex >= items.Count ? items.Count : newIndex < 0 ? 0 : newIndex;

        items.Insert(newIndex, slot);

        OnOrderUpdated?.Invoke();
    }