コード例 #1
0
            public void ProcessRequest(Security security, MarketDataMessage message, bool tryAdd)
            {
                if (message == null)
                {
                    throw new ArgumentNullException(nameof(message));
                }

                if (!tryAdd)
                {
                    var msg = (message.IsSubscribe ? LocalizedStrings.SubscriptionSent : LocalizedStrings.UnSubscriptionSent)
                              .Put(security?.Id, message.ToDataTypeString());

                    if (message.From != null && message.To != null)
                    {
                        msg += LocalizedStrings.Str691Params.Put(message.From.Value, message.To.Value);
                    }

                    _connector.AddDebugLog(msg + ".");
                }

                if (security == null)
                {
                    if (!message.IsSubscribe)
                    {
                        if (message.OriginalTransactionId != 0)
                        {
                            security = TryGetSecurity(message.OriginalTransactionId);
                        }
                    }
                }

                if (security == null)
                {
                    if (message.DataType != MarketDataTypes.News)
                    {
                        if (message.SecurityId.IsDefault())
                        {
                            throw new ArgumentNullException(nameof(security));
                        }

                        security = _connector.LookupById(message.SecurityId);

                        if (security == null)
                        {
                            throw new ArgumentException(LocalizedStrings.Str704Params.Put(message.SecurityId));
                        }
                    }
                }

                if (message.TransactionId == 0)
                {
                    message.TransactionId = _connector.TransactionIdGenerator.GetNextId();
                }

                if (security != null)
                {
                    message.FillSecurityInfo(_connector, security);
                }

                var value = Tuple.Create((MarketDataMessage)message.Clone(), security);

                if (tryAdd)
                {
                    // if the message was looped back via IsBack=true
                    _requests.TryAdd(message.TransactionId, value);
                }
                else
                {
                    _requests.Add(message.TransactionId, value);
                }

                _connector.SendInMessage(message);
            }