Advertisement
Guest User

Untitled

a guest
May 1st, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1.         public IReadable Pipe(IWriteable writeable)
  2.         {
  3.             this.OnData += data =>
  4.             {
  5.                 this.Pause();
  6.  
  7.                 writeable.Write(data, (exception) =>
  8.                 {
  9.                     if (exception != null)
  10.                     {
  11.                         if (this.OnError != null)
  12.                         {
  13.                             this.OnError(exception);
  14.                         }
  15.  
  16.                         return;
  17.                     }
  18.  
  19.                     this.Resume();
  20.                 });
  21.             };
  22.  
  23.             this.OnEnd += () =>
  24.             {
  25.                 writeable.End();
  26.             };
  27.  
  28.             if (writeable is IReadable)
  29.             {
  30.                 return writeable as IReadable;
  31.             }
  32.  
  33.             return null;
  34.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement