SessionElementLogReader.cs 895 B

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