Example #1
0
        // **********************************************************************

        public QshReaderImpl(FileStream fs, Stream ds)
            : base(fs)
        {
            dr = new DataReader(ds);

            AppName     = dr.ReadString();
            Comment     = dr.ReadString();
            RecDateTime = baseDateTime = new DateTime(dr.ReadInt64(), DateTimeKind.Utc);

            int streamsCount = dr.ReadByte();

            if (streamsCount == 0)
            {
                throw new Exception("Нет потоков данных");
            }

            streams = new QshStream[streamsCount];

            for (int i = 0; i < streams.Length; i++)
            {
                StreamType st = (StreamType)dr.ReadByte();

                switch (st)
                {
                case StreamType.Stock:
                    streams[i] = new StockStream(dr);
                    break;

                case StreamType.Deals:
                    streams[i] = new DealsStream(dr);
                    break;

                case StreamType.Orders:
                    streams[i] = new OrdersStream(dr);
                    break;

                case StreamType.Trades:
                    streams[i] = new TradesStream(dr);
                    break;

                case StreamType.Messages:
                    streams[i] = new MessagesStream(dr);
                    break;

                case StreamType.AuxInfo:
                    streams[i] = new AuxInfoStream(dr);
                    break;

                default:
                    throw new FormatException("Неизвестный тип данных: " + st);
                }
            }

            if (streams.Length == 1)
            {
                currentStream = streams[0];
            }

            ReadNextRecordHeader();
        }
    // **********************************************************************

    public QshReaderImpl(FileStream fs, Stream ds)
      : base(fs)
    {
      dr = new DataReader(ds);

      AppName = dr.ReadString();
      Comment = dr.ReadString();
      RecDateTime = baseDateTime = new DateTime(dr.ReadInt64(), DateTimeKind.Utc);

      int streamsCount = dr.ReadByte();

      if(streamsCount == 0)
        throw new Exception("Нет потоков данных");

      streams = new QshStream[streamsCount];

      for(int i = 0; i < streams.Length; i++)
      {
        StreamType st = (StreamType)dr.ReadByte();

        switch(st)
        {
          case StreamType.Stock:
            streams[i] = new StockStream(dr);
            break;

          case StreamType.Deals:
            streams[i] = new DealsStream(dr);
            break;

          case StreamType.Orders:
            streams[i] = new OrdersStream(dr);
            break;

          case StreamType.Trades:
            streams[i] = new TradesStream(dr);
            break;

          case StreamType.Messages:
            streams[i] = new MessagesStream(dr);
            break;

          case StreamType.AuxInfo:
            streams[i] = new AuxInfoStream(dr);
            break;

          default:
            throw new FormatException("Неизвестный тип данных: " + st);
        }
      }

      if(streams.Length == 1)
        currentStream = streams[0];

      ReadNextRecordHeader();
    }
Example #3
0
        // **********************************************************************

        void ReadNextRecordHeader()
        {
            try
            {
                CurrentDateTime = dr.ReadDateTime(ref baseDateTime);

                if (streams.Length > 1)
                {
                    CurrentStreamIndex = dr.ReadByte();
                    currentStream      = streams[CurrentStreamIndex];
                }
            }
            catch (EndOfStreamException)
            {
                CurrentDateTime = DateTime.MaxValue;
            }
        }
    // **********************************************************************

    void ReadNextRecordHeader()
    {
      try
      {
        CurrentDateTime = dr.ReadDateTime(ref baseDateTime);

        if(streams.Length > 1)
        {
          CurrentStreamIndex = dr.ReadByte();
          currentStream = streams[CurrentStreamIndex];
        }
      }
      catch(EndOfStreamException)
      {
        CurrentDateTime = DateTime.MaxValue;
      }
    }