Achamenes.ID3.Fields.BinaryField.WriteToStream C# (CSharp) Method

WriteToStream() public method

Writes the binary data field to a stream.
/// The passed stream was null. /// /// There was an IO exception while trying to write the field. /// /// The stream does not support writing. /// /// The passed stream was closed before the method was called. ///
public WriteToStream ( Stream stream ) : void
stream Stream The stream to write to.
return void
        public override void WriteToStream(Stream stream)
        {
            base.WriteToStream(stream);
            stream.Write(this._data, 0, this._data.Length);
        }

Usage Example

Beispiel #1
0
 public void TestWrite()
 {
     for(int testCase=0;testCase<100;testCase++)
     {
         byte[] randomData=new byte[_randomNumberGenerator.Next(1, 50000)];
         _randomNumberGenerator.NextBytes(randomData);
         BinaryField field=new BinaryField(randomData, 0, randomData.Length);
         MemoryStream stream=new MemoryStream();
         field.WriteToStream(stream);
         Assert.AreEqual(stream.Length, randomData.Length);
         for(int i = 0;i < randomData.Length;i++)
         {
             Assert.AreEqual(randomData[i], stream.GetBuffer()[i]);
         }
     }
 }