/// <summary>
        /// Initializes a new instance of the <see cref="BasicEventStream"/> class.
        /// </summary>
        /// <param name="dataStream">The data stream.</param>
        /// <param name="separator">The separator.</param>
        public BasicEventStream(IDataStream dataStream, string separator)
        {
            _dataStream = dataStream;
            _separator = separator;

            _contextGenerator = new BasicContextGenerator(_separator);
            if (_dataStream.HasNext())
            {
                _nextEvent = CreateEvent((string)_dataStream.NextToken());
            }
        }
 /// <summary>
 /// Returns the next Event object held in this EventStream. Each call to nextEvent advances the EventStream.
 /// </summary>
 /// <returns>
 /// The Event object which is next in this EventStream if there are any events in the stream;
 /// otherwise <c>null</c>.
 /// </returns>
 public override Event Next()
 {
     LoopForNextEvent();
     Event currentEvent = _nextEvent;
     if (_dataStream.HasNext())
     {
         _nextEvent = CreateEvent((string)_dataStream.NextToken());
     }
     else
     {
         _nextEvent = null;
     }
     return currentEvent;
 }
 private void LoopForNextEvent()
 {
     while (_nextEvent == null && _dataStream.HasNext())
     {
         _nextEvent = CreateEvent((string)_dataStream.NextToken());
     }
 }
 private Event CreateEvent(string obs)
 {
     int lastSeparator = obs.LastIndexOf(_separator);
     if (lastSeparator < 0)
     {
         return null;
     }
     Event e = new Event(obs.Substring(lastSeparator + 1), _contextGenerator.GetContext(obs.Substring(0, lastSeparator)));
     return e;
 }