Class BufferWriter
Auto-resizable buffer (similar to MemoryStream) but with methods to copy pointers any primitive arrays, not just byte[]. This class is typically used in conjunction with BufferReader.
Namespace: Microsoft.Psi.Common
Assembly: Microsoft.Psi.dll
Syntax
public class BufferWriter : object
Constructors
View SourceBufferWriter(Byte[])
Initializes a new instance of the BufferWriter class.
Declaration
public BufferWriter(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The underlying buffer to use in the beginning. The underlying buffer will change once it becomes insufficient. |
BufferWriter(Int32)
Initializes a new instance of the BufferWriter class.
Declaration
public BufferWriter(int size)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size | The initial size of the underlying buffer. |
Properties
View SourceBuffer
Gets the underlying buffer.
Declaration
public byte[] Buffer { get; }
Property Value
Type | Description |
---|---|
System.Byte[] |
Position
Gets the current position of the writer.
Declaration
public int Position { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Size
Gets the current size of the underlying buffer.
Declaration
public int Size { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
View SourceCopyFromStream(Stream, Int32)
Copies the specified number of bytes from a
Declaration
public void CopyFromStream(Stream stream, int count)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which to read. |
System.Int32 | count | The count of bytes to write. |
Reset()
Resets the writer without reallocating the underlying buffer.
Declaration
public void Reset()
Write(DateTime)
Writes a value of type DateTime to the underlying buffer.
Declaration
public void Write(DateTime source)
Parameters
Type | Name | Description |
---|---|---|
DateTime | source | The value to write. |
Write(Envelope)
Writes a value of type Envelope to the underlying buffer.
Declaration
public void Write(Envelope envelope)
Parameters
Type | Name | Description |
---|---|---|
Envelope | envelope | The value to write. |
Write(Boolean)
Writes a value of type bool to the underlying buffer.
Declaration
public void Write(bool source)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | source | The value to write. |
Write(Boolean[])
Writes an array of values of type Bool to the underlying buffer.
Declaration
public void Write(bool[] source)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean[] | source | The array to read from. |
Write(Byte)
Writes a value of type byte to the underlying buffer.
Declaration
public void Write(byte source)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | source | The value to write. |
Write(Byte[])
Writes an array of bytes to the underlying buffer.
Declaration
public void Write(byte[] source)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | source | The array of bytes to read from. |
Write(Char)
Writes a value of type Char to the underlying buffer.
Declaration
public void Write(char source)
Parameters
Type | Name | Description |
---|---|---|
System.Char | source | The value to write. |
Write(Char[])
Writes an array of values of type char to the underlying buffer.
Declaration
public void Write(char[] source)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | source | The array to read from. |
Write(Double)
Writes a value of type Double to the underlying buffer.
Declaration
public void Write(double source)
Parameters
Type | Name | Description |
---|---|---|
System.Double | source | The value to write. |
Write(Double[])
Writes an array of values of type Double to the underlying buffer.
Declaration
public void Write(double[] source)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | source | The array to read from. |
Write(Int16)
Writes a value of type Int16 to the underlying buffer.
Declaration
public void Write(short source)
Parameters
Type | Name | Description |
---|---|---|
System.Int16 | source | The value to write. |
Write(Int16[])
Writes an array of values of type Int16 to the underlying buffer.
Declaration
public void Write(short[] source)
Parameters
Type | Name | Description |
---|---|---|
System.Int16[] | source | The array to read from. |
Write(Int32)
Writes a value of type Int32 to the underlying buffer.
Declaration
public void Write(int source)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | source | The value to write. |
Write(Int32[])
Writes an array of values of type Int32 to the underlying buffer.
Declaration
public void Write(int[] source)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | source | The array to read from. |
Write(Int64)
Writes a value of type Int64 to the underlying buffer.
Declaration
public void Write(long source)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | source | The value to write. |
Write(Int64[])
Writes an array of values of type Int64 to the underlying buffer.
Declaration
public void Write(long[] source)
Parameters
Type | Name | Description |
---|---|---|
System.Int64[] | source | The array to read from. |
Write(SByte)
Writes a value of type sbyte to the underlying buffer.
Declaration
public void Write(sbyte source)
Parameters
Type | Name | Description |
---|---|---|
SByte | source | The value to write. |
Write(SByte[])
Writes an array of values of type SByte to the underlying buffer.
Declaration
public void Write(sbyte[] source)
Parameters
Type | Name | Description |
---|---|---|
SByte[] | source | The array to read from. |
Write(Single)
Writes a value of type Single to the underlying buffer.
Declaration
public void Write(float source)
Parameters
Type | Name | Description |
---|---|---|
Single | source | The value to write. |
Write(Single[])
Writes an array of values of type Single to the underlying buffer.
Declaration
public void Write(float[] source)
Parameters
Type | Name | Description |
---|---|---|
Single[] | source | The array to read from. |
Write(String)
Writes a value of type String to the underlying buffer.
Declaration
public void Write(string source)
Parameters
Type | Name | Description |
---|---|---|
String | source | The value to write. |
Write(UInt16)
Writes a value of type UInt16 to the underlying buffer.
Declaration
public void Write(ushort source)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | source | The value to write. |
Write(UInt16[])
Writes an array of values of type UInt16 to the underlying buffer.
Declaration
public void Write(ushort[] source)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16[] | source | The array to read from. |
Write(UInt32)
Writes a value of type UInt32 to the underlying buffer.
Declaration
public void Write(uint source)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | source | The value to write. |
Write(UInt32[])
Writes an array of values of type UInt32 to the underlying buffer.
Declaration
public void Write(uint[] source)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32[] | source | The array to read from. |
Write(UInt64)
Writes a value of type UInt64 to the underlying buffer.
Declaration
public void Write(ulong source)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | source | The value to write. |
Write(UInt64[])
Writes an array of values of type UInt64 to the underlying buffer.
Declaration
public void Write(ulong[] source)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64[] | source | The array to read from. |
Write(Void*, Int32)
Writes the specified number of bytes from the specified address.
Declaration
public void Write(void *source, int lengthInBytes)
Parameters
Type | Name | Description |
---|---|---|
Void* | source | The pointer to the memory to copy into the buffer. |
System.Int32 | lengthInBytes | The number of bytes to copy. |
WriteEx(Byte[], Int32, Int32)
Writes a portion of an array of bytes to the underlying buffer.
Declaration
public void WriteEx(byte[] source, int start, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | source | The array of bytes to read from. |
System.Int32 | start | The index into the source array to start reading from. |
System.Int32 | count | The count of bytes to write. |