Пример #1
0
        internal MarketMessageSubscriptionData(Subscription sub, Dictionary <string, object> fields) : base(new Name("MarketDataEvents"), sub.CorrelationID, null)
        {
            this._fields = new Dictionary <string, Element>();
            foreach (var item in fields)
            {
                Element elm = null;
                if (item.Value is double)
                {
                    elm = new MarketElementDouble(item.Key, (double)item.Value);
                }

                else if (item.Value is Datetime)
                {
                    Datetime temp = (Datetime)item.Value;

                    bool isDate     = temp.HasParts(Datetime.DATE);
                    bool isTime     = temp.HasParts(Datetime.TIME);
                    bool isDatetime = isDate && isTime;

                    if (isDatetime)
                    {
                        elm = new MarketElementDatetime(item.Key, temp.ToSystemDateTime());
                    }
                    else if (isDate)
                    {
                        elm = new MarketElementDate(item.Key, temp.ToSystemDateTime());
                    }
                    else if (isTime)
                    {
                        elm = new MarketElementTime(item.Key, temp.ToSystemDateTime());
                    }
                }

                else if (item.Value is int)
                {
                    elm = new MarketElementInt(item.Key, (int)item.Value);
                }
                else if (item.Value is string)
                {
                    elm = new MarketElementString(item.Key, (string)item.Value);
                }
                else if (item.Value is bool)
                {
                    elm = new MarketElementBool(item.Key, (bool)item.Value);
                }

                if (elm != null)
                {
                    this._fields.Add(item.Key, elm);
                }
            }
            this._security = sub.Security;
        }