X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem.IO%2FStream.cs;h=d6e0359a86713b8a913ee9e47ef0c26ca95d9569;hb=3c39ac4586b4470703fb4af0208b5baf1de70e43;hp=6623da319a197f5604f918802b458c7820b7161c;hpb=7e18ed47c9606f3981e7b18cbc238d6781843153;p=mono.git diff --git a/mcs/class/corlib/System.IO/Stream.cs b/mcs/class/corlib/System.IO/Stream.cs index 6623da319a1..d6e0359a867 100644 --- a/mcs/class/corlib/System.IO/Stream.cs +++ b/mcs/class/corlib/System.IO/Stream.cs @@ -1,5 +1,5 @@ // -// System.IO/Stream.cs +// System.IO.Stream.cs // // Authors: // Dietmar Maurer (dietmar@ximian.com) @@ -40,7 +40,12 @@ using System.Runtime.InteropServices; namespace System.IO { [Serializable] + [ComVisible (true)] +#if NET_2_1 + public abstract class Stream : IDisposable +#else public abstract class Stream : MarshalByRefObject, IDisposable +#endif { public static readonly Stream Null = new NullStream (); @@ -63,6 +68,13 @@ namespace System.IO get; } + [ComVisible (false)] + public virtual bool CanTimeout { + get { + return false; + } + } + public abstract long Length { get; @@ -75,15 +87,52 @@ namespace System.IO } + // 2.0 version of Dispose. + public void Dispose () + { + Close (); + } + + // 2.0 version of Dispose. + protected virtual void Dispose (bool disposing) + { + // nothing. + } + + // + // 2.0 version of Close (): calls Dispose (true) + // public virtual void Close () { + Dispose (true); + } + + [ComVisible (false)] + public virtual int ReadTimeout { + get { + throw new InvalidOperationException ("Timeouts are not supported on this stream."); + } + set { + throw new InvalidOperationException ("Timeouts are not supported on this stream."); + } + } + + [ComVisible (false)] + public virtual int WriteTimeout { + get { + throw new InvalidOperationException ("Timeouts are not supported on this stream."); + } + set { + throw new InvalidOperationException ("Timeouts are not supported on this stream."); + } } - void IDisposable.Dispose () + public static Stream Synchronized (Stream stream) { - Close (); + throw new NotImplementedException (); } + [Obsolete ("CreateWaitHandle is due for removal. Use \"new ManualResetEvent(false)\" instead.")] protected virtual WaitHandle CreateWaitHandle() { return new ManualResetEvent (false); @@ -119,7 +168,7 @@ namespace System.IO } public virtual IAsyncResult - BeginRead (byte [] buffer, int offset, int count, AsyncCallback cback, object state) + BeginRead (byte [] buffer, int offset, int count, AsyncCallback callback, object state) { if (!CanRead) throw new NotSupportedException ("This stream does not support reading"); @@ -140,16 +189,16 @@ namespace System.IO result.SetComplete (e, 0); } - if (cback != null) - cback (result); + if (callback != null) + callback (result); return result; } - delegate void WriteDelegate (byte [] buffer, int offset, int count); +// delegate void WriteDelegate (byte [] buffer, int offset, int count); public virtual IAsyncResult - BeginWrite (byte [] buffer, int offset, int count, AsyncCallback cback, object state) + BeginWrite (byte [] buffer, int offset, int count, AsyncCallback callback, object state) { if (!CanWrite) throw new NotSupportedException ("This stream does not support writing"); @@ -170,20 +219,20 @@ namespace System.IO result.SetComplete (e); } - if (cback != null) - cback.BeginInvoke (result, null, null); + if (callback != null) + callback.BeginInvoke (result, null, null); return result; } - public virtual int EndRead (IAsyncResult async_result) + public virtual int EndRead (IAsyncResult asyncResult) { - if (async_result == null) - throw new ArgumentNullException ("async_result"); + if (asyncResult == null) + throw new ArgumentNullException ("asyncResult"); - StreamAsyncResult result = async_result as StreamAsyncResult; + StreamAsyncResult result = asyncResult as StreamAsyncResult; if (result == null || result.NBytes == -1) - throw new ArgumentException ("Invalid IAsyncResult", "async_result"); + throw new ArgumentException ("Invalid IAsyncResult", "asyncResult"); if (result.Done) throw new InvalidOperationException ("EndRead already called."); @@ -195,14 +244,14 @@ namespace System.IO return result.NBytes; } - public virtual void EndWrite (IAsyncResult async_result) + public virtual void EndWrite (IAsyncResult asyncResult) { - if (async_result == null) - throw new ArgumentNullException ("async_result"); + if (asyncResult == null) + throw new ArgumentNullException ("asyncResult"); - StreamAsyncResult result = async_result as StreamAsyncResult; + StreamAsyncResult result = asyncResult as StreamAsyncResult; if (result == null || result.NBytes != -1) - throw new ArgumentException ("Invalid IAsyncResult", "async_result"); + throw new ArgumentException ("Invalid IAsyncResult", "asyncResult"); if (result.Done) throw new InvalidOperationException ("EndWrite already called."); @@ -256,9 +305,7 @@ namespace System.IO { } - public override int Read (byte[] buffer, - int offset, - int count) + public override int Read (byte[] buffer, int offset, int count) { return 0; } @@ -268,8 +315,7 @@ namespace System.IO return -1; } - public override long Seek (long offset, - SeekOrigin origin) + public override long Seek (long offset, SeekOrigin origin) { return 0; } @@ -278,9 +324,7 @@ namespace System.IO { } - public override void Write (byte[] buffer, - int offset, - int count) + public override void Write (byte[] buffer, int offset, int count) { }