/// <summary> /// Instrument profiles parser operations. /// </summary> /// <param name="inputStream">Decompressed input stream of instrument profiles.</param> /// <returns>Number of received instrument profiles.</returns> private void Process(Stream inputStream) { var parser = new InstrumentProfileParser(inputStream); parser.OnFlush += Flush; parser.OnComplete += Complete; InstrumentProfile instrumentProfile; while ((instrumentProfile = parser.Next()) != null) { ipBuffer.Add(instrumentProfile); if (CurrentState == State.Closed) { return; } } // EOF of live connection is _NOT_ a signal that snapshot was complete (it sends an explicit complete) // for non-live data sources, though, EOF is a completion signal if (!supportsLive) { Complete(this, new EventArgs()); } }
/// <summary> /// Reads and returns instrument profiles from specified stream. /// </summary> /// <param name="inputStream">Stream from which read profiles.</param> /// <returns>Instrument profiles from specified stream.</returns> /// <exception cref="ArgumentException">Stream does not support reading.</exception> /// <exception cref="ArgumentNullException">Stream is null.</exception> /// <exception cref="IOException">If an I/O error occurs.</exception> /// <exception cref="InstrumentProfileFormatException">If input stream does not conform to the Simple File Format.</exception> public IList <InstrumentProfile> Read(Stream inputStream) { IList <InstrumentProfile> profiles = new List <InstrumentProfile>(); InstrumentProfileParser parser = new InstrumentProfileParser(inputStream); InstrumentProfile ip; while ((ip = parser.Next()) != null) { try { profiles.Add(ip); } catch (Exception exc) { throw new IOException("Read failed: " + exc); } } return(profiles); }