andrew4582

AbstractStreamBase

Aug 19th, 2011
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.97 KB | None | 0 0
  1. //--------------------------------------------------------------------------
  2. //
  3. //  Copyright (c) Microsoft Corporation.  All rights reserved.
  4. //
  5. //  File: AbstractStreamBase.cs
  6. //
  7. //--------------------------------------------------------------------------
  8.  
  9. namespace System.IO
  10. {
  11.     /// <summary>Base stream class that implements all of Stream's abstract members.</summary>
  12.     public abstract class AbstractStreamBase : Stream
  13.     {
  14.         /// <summary>Determines whether data can be read from the stream.</summary>
  15.         public override bool CanRead { get { return false; } }
  16.         /// <summary>Determines whether data can be written to the stream.</summary>
  17.         public override bool CanWrite { get { return false; } }
  18.         /// <summary>Determines whether the stream can be seeked.</summary>
  19.         public override bool CanSeek { get { return false; } }
  20.         /// <summary>Flushes the contents of the stream to the underlying storage.</summary>
  21.         public override void Flush() { }
  22.  
  23.         /// <summary>Gets the length of the stream.</summary>
  24.         public override long Length { get { throw new NotSupportedException(); } }
  25.  
  26.         /// <summary>Gets or sets the current position of the stream.</summary>
  27.         public override long Position
  28.         {
  29.             get { throw new NotSupportedException(); }
  30.             set { throw new NotSupportedException(); }
  31.         }
  32.  
  33.         /// <summary>
  34.         /// Reads a sequence of bytes from the current
  35.         /// stream and advances the position within the stream by the number of bytes read.
  36.         /// </summary>
  37.         /// <param name="buffer">
  38.         /// An array of bytes. When Read returns, the buffer contains the specified
  39.         /// byte array with the values between offset and (offset + count - 1) replaced
  40.         /// by the bytes read from the current source.
  41.         /// </param>
  42.         /// <param name="offset">
  43.         /// The zero-based byte offset in buffer at which to begin storing the data read
  44.         /// from the current stream.
  45.         /// </param>
  46.         /// <param name="count">The maximum number of bytes to be read from the current stream.</param>
  47.         /// <returns>
  48.         /// The total number of bytes read into the buffer. This can be less than the
  49.         /// number of bytes requested if that many bytes are not currently available,
  50.         /// or zero (0) if the end of the stream has been reached.
  51.         /// </returns>
  52.         public override int Read(byte[] buffer, int offset, int count)
  53.         {
  54.             throw new NotSupportedException();
  55.         }
  56.  
  57.         /// <summary>Sets the position within the current stream.</summary>
  58.         /// <param name="offset">A byte offset relative to the origin parameter.</param>
  59.         /// <param name="origin">
  60.         /// A value of type System.IO.SeekOrigin indicating the reference point used
  61.         /// to obtain the new position.
  62.         /// </param>
  63.         /// <returns>The new position within the current stream.</returns>
  64.         public override long Seek(long offset, SeekOrigin origin)
  65.         {
  66.             throw new NotSupportedException();
  67.         }
  68.  
  69.         /// <summary>Sets the length of the current stream.</summary>
  70.         /// <param name="value">The desired length of the current stream in bytes.</param>
  71.         public override void SetLength(long value)
  72.         {
  73.             throw new NotSupportedException();
  74.         }
  75.  
  76.         /// <summary>Writes a sequence of bytes to the stream.</summary>
  77.         /// <param name="buffer">An array of bytes. Write copies count bytes from buffer to the stream.</param>
  78.         /// <param name="offset">The zero-based byte offset in buffer at which to begin copying bytes to the stream.</param>
  79.         /// <param name="count">The number of bytes to be written to the current stream.</param>
  80.         public override void Write(byte[] buffer, int offset, int count)
  81.         {
  82.             throw new NotSupportedException();
  83.         }
  84.     }
  85. }
Add Comment
Please, Sign In to add comment