Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. public class XclStream : System.IO.Stream
  2. {
  3. private System.IO.Stream _baseStream = null;
  4. private bool _cancelled = false;
  5.  
  6. public XclStream(System.IO.Stream baseStream) : base()
  7. {
  8. _baseStream = baseStream;
  9. }
  10.  
  11. public void Cancel()
  12. {
  13. _cancelled = true;
  14. }
  15.  
  16. public override int Read(byte[] buffer, int offset, int count)
  17. {
  18. if (_cancelled == true)
  19. {
  20. throw new StreamCancelledException();
  21. }
  22.  
  23. return _baseStream.Read(buffer, offset, count);
  24. }
  25.  
  26. //TODO: override all other Stream methods...
  27. }
  28.  
  29. public class StreamCancelledException : Exception
  30. {
  31. public StreamCancelledException() : base("Stream cancelled. Byebye, xmlreader...") { }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement