SessionElementLogReader.cs 840 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace WinSCP
  5. {
  6. internal class SessionElementLogReader : ElementLogReader
  7. {
  8. public SessionElementLogReader(CustomLogReader parentReader) :
  9. base(parentReader)
  10. {
  11. }
  12. public override void Dispose()
  13. {
  14. // Now it's ok if we encounter </session>.
  15. _disposing = true;
  16. base.Dispose();
  17. }
  18. public override bool Read(LogReadFlags flags)
  19. {
  20. bool result = base.Read(flags);
  21. if (_read && !_disposing)
  22. {
  23. throw new SessionLocalException(Session, "Session has unexpectedly closed");
  24. }
  25. return result;
  26. }
  27. private bool _disposing;
  28. }
  29. }