コード例 #1
0
 public bool TryReadTick(TickIO tickIO)
 {
     if (!isInitialized)
     {
         return(false);
     }
     if (dataIn == null || tickCount > MaxCount || endOfData)
     {
         return(false);
     }
     try
     {
         do
         {
             tickIO.SetSymbol(lSymbol);
             byte size = dataIn.ReadByte();
             // Check for old style prior to version 8 where
             // single byte version # was first.
             if (dataVersion < 8 && size < 8)
             {
                 dataVersion = tickIO.FromReader((byte)size, dataIn);
             }
             else
             {
                 // Subtract the size byte.
                 //if (dataIn.BaseStream.Position + size - 1 > length) {
                 //    return false;
                 //}
                 int count = 1;
                 memory.SetLength(size);
                 memory.GetBuffer()[0] = size;
                 while (count < size)
                 {
                     var bytesRead = dataIn.Read(buffer, count, size - count);
                     if (bytesRead == 0)
                     {
                         return(false);
                     }
                     count += bytesRead;
                 }
                 memory.Position = 0;
                 dataVersion     = tickIO.FromReader(memory);
             }
             var utcTime = new TimeStamp(tickIO.lUtcTime);
             if (utcTime > EndTime)
             {
                 ReportEndOfData();
                 return(false);
             }
             tickIO.SetTime(utcTime);
             tickCount++;
         } while (tickIO.UtcTime < StartTime);
         return(true);
     }
     catch (EndOfStreamException ex)
     {
         ReportEndOfData();
         return(false);
     }
 }
コード例 #2
0
 public bool TryReadTick(TickIO tickIO)
 {
     try
     {
         if (memory.Position >= tickBlockHeader.blockHeader.length)
         {
             return(false);
         }
         tickIO.SetSymbol(tickIO.lSymbol);
         var size = memory.GetBuffer()[memory.Position];
         dataVersion = tickIO.FromReader(memory);
         var utcTime = new TimeStamp(tickIO.lUtcTime);
         tickIO.SetTime(utcTime);
         return(true);
     }
     catch (EndOfStreamException ex)
     {
         return(false);
     }
     catch (IndexOutOfRangeException)
     {
         int x = 0;
         return(false);
     }
 }