CSharpTest.Net
CombinedStream Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : CombinedStream Class

Glossary Item Box

Creates a single 'pseudo' stream out of multiple input streams

Syntax

Visual Basic (Declaration) 
Public Class CombinedStream 
   Inherits BaseStream
C# 
public class CombinedStream : BaseStream 

Example

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.NETCopy 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?

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.IO.Stream
         CSharpTest.Net.IO.BaseStream
            CSharpTest.Net.IO.CombinedStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys