Show / Hide Table of Contents

Class BinaryWriterExtensions

Contains useful extensions for the BinaryWriter class.

Inheritance
object
BinaryWriterExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: TheXDS.MCART.Types.Extensions
Assembly: MCART.dll
Syntax
public static class BinaryWriterExtensions

Methods

| Edit this page View Source

DynamicWrite(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 bw or value are null.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX