Visual Basic (Declaration) | |
---|---|
Public Class ClampedStream Inherits System.IO.Stream |
C# | |
---|---|
public class ClampedStream : System.IO.Stream |
Library/Library.Test/TestClampedStream.cs
C# | Copy Code |
---|---|
using (MemoryStream ms = new MemoryStream(SequencedBytes(20))) using (Stream s = new ClampedStream(ms, 10, 5)) { byte[] test = new byte[200]; Assert.AreEqual(5, s.Read(test, 0, 200)); Array.Resize(ref test, 5); Assert.AreEqual(new byte[] { 10, 11, 12, 13, 14 }, test); s.Position = 0; s.Write(new byte[] { 1, 2, 3, 4, 5 }, 0, 5); s.Position = 0; Assert.AreEqual(new byte[] { 1, 2, 3, 4, 5 }, IOStream.ReadAllBytes(s)); } |
VB.NET | Copy Code |
---|---|
Using ms As New MemoryStream(SequencedBytes(20)) Using s As Stream = New ClampedStream(ms, 10, 5) Dim test As Byte() = New Byte(200) {} Assert.AreEqual(5, s.Read(test, 0, 200)) Array.Resize(test, 5) Assert.AreEqual(New Byte() {10, 11, 12, 13, 14}, test) s.Position = 0 s.Write(New Byte() {1, 2, 3, 4, 5}, 0, 5) s.Position = 0 Assert.AreEqual(New Byte() {1, 2, 3, 4, 5}, IOStream.ReadAllBytes(s)) End Using End Using |
System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.ClampedStream
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7