コード例 #1
0
 public EncoderStream(Stream stream, ByteEncoder encoder, EncoderStreamAccess access)
 {
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
     if (encoder == null)
     {
         throw new ArgumentNullException("encoder");
     }
     if (access == EncoderStreamAccess.Read)
     {
         if (!stream.CanRead)
         {
             throw new NotSupportedException(EncodersStrings.EncStrCannotRead);
         }
     }
     else if (!stream.CanWrite)
     {
         throw new NotSupportedException(EncodersStrings.EncStrCannotWrite);
     }
     this.stream     = stream;
     this.encoder    = encoder;
     this.access     = access;
     this.ownsStream = true;
     this.length     = long.MaxValue;
     this.buffer     = new byte[4096];
 }
コード例 #2
0
ファイル: EncoderStream.cs プロジェクト: Rhombulus/Mime
 internal EncoderStream(System.IO.Stream stream, ByteEncoder encoder, EncoderStreamAccess access, bool ownsStream)
 {
     if (stream == null)
         throw new System.ArgumentNullException(nameof(stream));
     if (encoder == null)
         throw new System.ArgumentNullException(nameof(encoder));
     if (access == EncoderStreamAccess.Read) {
         if (!stream.CanRead)
             throw new System.NotSupportedException(Resources.EncodersStrings.EncStrCannotRead);
     } else if (!stream.CanWrite)
         throw new System.NotSupportedException(Resources.EncodersStrings.EncStrCannotWrite);
     this.stream = stream;
     this.encoder = encoder;
     this.access = access;
     this.ownsStream = ownsStream;
     length = long.MaxValue;
     buffer = new byte[4096];
 }