Class BinaryWriterExtensions
Contains useful extensions for the BinaryWriter class.
Inherited Members
Namespace: TheXDS.MCART.Types.Extensions
Assembly: MCART.dll
Syntax
public static class BinaryWriterExtensions
Methods
| Edit this page View SourceDynamicWrite(BinaryWriter, object)
Performs a write of the specified object, dynamically determining the appropriate write method to use.
Declaration
public static void DynamicWrite(this BinaryWriter bw, object value)
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | bw | The instance to perform the writing on. |
object | value | The object to write. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if it has not been possible to find a method that can write the specified value. |
ArgumentNullException | Thrown if |
MarshalWriteStructArray<T>(BinaryWriter, T[])
Writes an array of structures to the underlying stream using Marshaling.
Declaration
public static int MarshalWriteStructArray<T>(this BinaryWriter bw, T[] array) where T : struct
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | bw | Binary writer to use when writing the array. |
T[] | array | Array of values to write. |
Returns
Type | Description |
---|---|
int | The number of bytes written to the stream. |
Type Parameters
Name | Description |
---|---|
T | Type of structure array to write. |
MarshalWriteStruct<T>(BinaryWriter, T)
Writes a simple structure to the underlying Stream via Marshaling.
Declaration
public static int MarshalWriteStruct<T>(this BinaryWriter bw, T value) where T : struct
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | bw | The instance to perform the writing on. |
T | value | The object to write. |
Returns
Type | Description |
---|---|
int |
Type Parameters
Name | Description |
---|---|
T | Type of the structure. |
Write(BinaryWriter, DateTime)
Writes a DateTime to the specified BinaryWriter.
Declaration
public static void Write(this BinaryWriter bw, DateTime value)
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | bw | The instance to perform the writing on. |
DateTime | value | The value to write. |
Write(BinaryWriter, Enum)
Writes an Enum value to the specified BinaryWriter.
Declaration
public static void Write(this BinaryWriter bw, Enum value)
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | bw | The instance to perform the writing on. |
Enum | value | The value to write. |
Write(BinaryWriter, Guid)
Writes a Guid to the specified BinaryWriter.
Declaration
public static void Write(this BinaryWriter bw, Guid value)
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | bw | The instance to perform the writing on. |
Guid | value | The value to write. |
Write(BinaryWriter, ISerializable)
Writes a serializable object to the specified BinaryWriter.
Declaration
public static void Write(this BinaryWriter bw, ISerializable value)
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | bw | The instance to perform the writing on. |
ISerializable | value | The serializable object to write. |
Write(BinaryWriter, TimeSpan)
Writes a TimeSpan to the specified BinaryWriter.
Declaration
public static void Write(this BinaryWriter bw, TimeSpan value)
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | bw | The instance to perform the writing on. |
TimeSpan | value | The value to write. |
WriteNullTerminatedString(BinaryWriter, string)
Writes a null-terminated string to the specified BinaryWriter, using UTF-8 encoding.
Declaration
public static void WriteNullTerminatedString(this BinaryWriter bw, string value)
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | bw | The instance to perform the writing on. |
string | value | The string to write. |
WriteNullTerminatedString(BinaryWriter, string, Encoding)
Writes a null-terminated string to the specified BinaryWriter.
Declaration
public static void WriteNullTerminatedString(this BinaryWriter bw, string value, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | bw | The instance to perform the writing on. |
string | value | The string to write. |
Encoding | encoding | The encoding to use for writing the string. |
WriteStruct<T>(BinaryWriter, T)
Writes a simple structure to the underlying Stream
Declaration
public static void WriteStruct<T>(this BinaryWriter bw, T value) where T : struct
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | bw | The instance to perform the writing on. |
T | value | The object to write. |
Type Parameters
Name | Description |
---|---|
T | Type of the structure. |