Visual Basic (Declaration) | |
---|---|
Public Class DisposingStream Inherits AggregateStream |
C# | |
---|---|
public class DisposingStream : AggregateStream |
Library/Library.Test/TestStreams.cs
C# | Copy Code |
---|---|
DisposableFlag f1 = new DisposableFlag(); DisposableFlag f2 = new DisposableFlag(); Assert.IsFalse(f1.Disposed || f2.Disposed); Stream ms1 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1); Stream ms2 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2); using (Stream cs = new CombinedStream(ms1, ms2)) { } Assert.IsTrue(f1.Disposed && f2.Disposed);//even though not read, we did dispose? |
VB.NET | Copy Code |
---|---|
Dim f1 As New DisposableFlag() Dim f2 As New DisposableFlag() Assert.IsFalse(f1.Disposed OrElse f2.Disposed) Dim ms1 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1) Dim ms2 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2) Using cs As Stream = New CombinedStream(ms1, ms2) End Using Assert.IsTrue(f1.Disposed AndAlso f2.Disposed) 'even though not read, we did dispose? |
System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.AggregateStream
CSharpTest.Net.IO.DisposingStream
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
DisposingStream MembersCSharpTest.Net.IO Namespace