C# Class GSF.IO.StreamExtensions

Defines extension functions related to Stream manipulation.
显示文件 Open project: GridProtectionAlliance/gsf

Public Methods

Method Description
CopyTo ( this source, Stream destination, long length, byte buffer ) : void

Writes the contents of a stream to the provided stream.

Read7BitUInt32 ( this stream ) : uint

Reads the 7-bit encoded value from the stream.

ReadAll ( this stream, byte buffer, int position, int length ) : void

Reads all of the provided bytes. Will not return prematurely, but continue to execute a Stream.Read command until the entire length has been read.

ReadBoolean ( this stream ) : bool

Reads the value from the stream in little endian format.

ReadBytes ( this stream ) : byte[]

Reads a byte array from a Stream. The number of bytes should be prefixed in the stream.

ReadBytes ( this stream, int length ) : byte[]

Reads a byte array from a Stream. The number of bytes should be prefixed in the stream.

ReadChar ( this stream ) : char

Reads the value from the stream in little endian format.

ReadDateTime ( this stream ) : System.DateTime

Reads the value from the stream in little endian format.

ReadDecimal ( this stream ) : decimal

Reads a decimal from the stream in Little Endian bytes.

ReadDouble ( this stream ) : double

Reads the value from the stream in little endian format.

ReadGuid ( this stream ) : System.Guid

Reads a Guid from the stream in Little Endian bytes.

ReadInt16 ( this stream ) : short

Reads the value from the stream in little endian format.

ReadInt32 ( this stream ) : int

Reads the value from the stream in little endian format.

ReadInt32Collection ( this stream ) : int[]

Writes the supplied string to a Stream in UTF8 encoding.

ReadInt64 ( this stream ) : long

Reads the value from the stream in little endian format.

ReadNullableString ( this stream ) : string

Reads a string from a Stream that was encoded in UTF8. Value can be null and is prefixed with a boolean.

ReadObject ( this stream ) : object

Reads an object from a stream.

ReadSByte ( this stream ) : sbyte

Reads the value from the stream in little endian format.

ReadSingle ( this stream ) : float

Reads the value from the stream in little endian format.

ReadStream ( this source ) : byte[]

Reads entire Stream contents, and returns byte array of data.

ReadString ( this stream ) : string

Reads a string from a Stream that was encoded in UTF8.

ReadStringCollection ( this stream ) : string[]

Writes the supplied string to a Stream in UTF8 encoding.

ReadUInt16 ( this stream ) : ushort

Reads the value from the stream in little endian format.

ReadUInt32 ( this stream ) : uint

Reads the value from the stream in little endian format.

ReadUInt64 ( this stream ) : ulong

Reads the value from the stream in little endian format.

Write ( this stream, System.DateTime value ) : void

Writes the supplied value to stream in little endian format.

Write ( this stream, System.Guid value ) : void

Writes a guid in little endian bytes to the stream

Write ( this stream, bool value ) : void

Writes the supplied value to stream in little endian format.

Write ( this stream, byte value ) : void

Writes the supplied value to in little endian format.

Write ( this stream, char value ) : void

Writes the supplied value to stream in little endian format.

Write ( this stream, decimal value ) : void

Writes the supplied string to a Stream in UTF8 encoding.

Write ( this stream, double value ) : void

Writes the supplied value to stream in little endian format.

Write ( this stream, float value ) : void

Writes the supplied value to stream in little endian format.

Write ( this stream, int value ) : void

Writes the supplied value to stream in little endian format.

Write ( this stream, long value ) : void

Writes the supplied value to stream in little endian format.

Write ( this stream, sbyte value ) : void

Writes the supplied value to stream in little endian format.

Write ( this stream, short value ) : void

Writes the supplied value to stream in little endian format.

Write ( this stream, string value ) : void

Writes the supplied string to a Stream in UTF8 encoding.

Write ( this stream, uint value ) : void

Writes the supplied value to stream in little endian format.

Write ( this stream, ulong value ) : void

Writes the supplied value to stream in little endian format.

Write ( this stream, ushort value ) : void

Writes the supplied value to stream in little endian format.

WriteCollection ( this stream, ICollection collection ) : void

Writes the supplied Collection to a Stream.

WriteCollection ( this stream, ICollection collection ) : void

Writes the supplied Collection to a Stream.

WriteNullable ( this stream, string value ) : void

Writes the supplied string to a Stream in UTF8 encoding with a prefix if the value is null

WriteWithLength ( this stream, byte value ) : void

Writes the supplied value to stream along with prefixing the length so it can be properly read as a unit.

Private Methods

Method Description
CopyStream ( this source, Stream destination ) : void
ReadNextByte ( this stream ) : byte
ThrowEOS ( ) : void
WriteObject ( this stream, object value ) : void

Method Details

CopyTo() public static method

Writes the contents of a stream to the provided stream.
public static CopyTo ( this source, Stream destination, long length, byte buffer ) : void
source this the source stream
destination Stream the destination stream.
length long the number of bytes to copy. If the source is not long enough, /// and end of stream exception will be thrown.
buffer byte A buffer to use to copy the data from one stream to another. /// This keeps the function from always allocating a new buffer for the copy
return void

Read7BitUInt32() public static method

Reads the 7-bit encoded value from the stream.
public static Read7BitUInt32 ( this stream ) : uint
stream this
return uint

ReadAll() public static method

Reads all of the provided bytes. Will not return prematurely, but continue to execute a Stream.Read command until the entire length has been read.
occurs if the end of the stream has been reached.
public static ReadAll ( this stream, byte buffer, int position, int length ) : void
stream this The stream to read from
buffer byte The buffer to write to
position int the start position in the
length int the number of bytes to read
return void

ReadBoolean() public static method

Reads the value from the stream in little endian format.
public static ReadBoolean ( this stream ) : bool
stream this the stream to read from.
return bool

ReadBytes() public static method

Reads a byte array from a Stream. The number of bytes should be prefixed in the stream.
public static ReadBytes ( this stream ) : byte[]
stream this the stream to read from
return byte[]

ReadBytes() public static method

Reads a byte array from a Stream. The number of bytes should be prefixed in the stream.
public static ReadBytes ( this stream, int length ) : byte[]
stream this the stream to read from
length int gets the number of bytes to read.
return byte[]

ReadChar() public static method

Reads the value from the stream in little endian format.
public static ReadChar ( this stream ) : char
stream this the stream to read from.
return char

ReadDateTime() public static method

Reads the value from the stream in little endian format.
public static ReadDateTime ( this stream ) : System.DateTime
stream this the stream to read from.
return System.DateTime

ReadDecimal() public static method

Reads a decimal from the stream in Little Endian bytes.
public static ReadDecimal ( this stream ) : decimal
stream this the stream to read the decimal from.
return decimal

ReadDouble() public static method

Reads the value from the stream in little endian format.
public static ReadDouble ( this stream ) : double
stream this the stream to read from.
return double

ReadGuid() public static method

Reads a Guid from the stream in Little Endian bytes.
public static ReadGuid ( this stream ) : System.Guid
stream this the stream to read the guid from.
return System.Guid

ReadInt16() public static method

Reads the value from the stream in little endian format.
public static ReadInt16 ( this stream ) : short
stream this the stream to read from.
return short

ReadInt32() public static method

Reads the value from the stream in little endian format.
public static ReadInt32 ( this stream ) : int
stream this the stream to read from.
return int

ReadInt32Collection() public static method

Writes the supplied string to a Stream in UTF8 encoding.
public static ReadInt32Collection ( this stream ) : int[]
stream this
return int[]

ReadInt64() public static method

Reads the value from the stream in little endian format.
public static ReadInt64 ( this stream ) : long
stream this the stream to read from.
return long

ReadNullableString() public static method

Reads a string from a Stream that was encoded in UTF8. Value can be null and is prefixed with a boolean.
public static ReadNullableString ( this stream ) : string
stream this
return string

ReadObject() public static method

Reads an object from a stream.
public static ReadObject ( this stream ) : object
stream this Source stream.
return object

ReadSByte() public static method

Reads the value from the stream in little endian format.
public static ReadSByte ( this stream ) : sbyte
stream this the stream to read from.
return sbyte

ReadSingle() public static method

Reads the value from the stream in little endian format.
public static ReadSingle ( this stream ) : float
stream this the stream to read from.
return float

ReadStream() public static method

Reads entire Stream contents, and returns byte array of data.
public static ReadStream ( this source ) : byte[]
source this The to be converted to array.
return byte[]

ReadString() public static method

Reads a string from a Stream that was encoded in UTF8.
public static ReadString ( this stream ) : string
stream this
return string

ReadStringCollection() public static method

Writes the supplied string to a Stream in UTF8 encoding.
public static ReadStringCollection ( this stream ) : string[]
stream this
return string[]

ReadUInt16() public static method

Reads the value from the stream in little endian format.
public static ReadUInt16 ( this stream ) : ushort
stream this the stream to read from.
return ushort

ReadUInt32() public static method

Reads the value from the stream in little endian format.
public static ReadUInt32 ( this stream ) : uint
stream this the stream to read from.
return uint

ReadUInt64() public static method

Reads the value from the stream in little endian format.
public static ReadUInt64 ( this stream ) : ulong
stream this the stream to read from.
return ulong

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, System.DateTime value ) : void
stream this the stream to write to
value System.DateTime the value to write
return void

Write() public static method

Writes a guid in little endian bytes to the stream
public static Write ( this stream, System.Guid value ) : void
stream this
value System.Guid
return void

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, bool value ) : void
stream this the stream to write to
value bool the value to write
return void

Write() public static method

Writes the supplied value to in little endian format.
public static Write ( this stream, byte value ) : void
stream this the stream to write to
value byte the value to write
return void

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, char value ) : void
stream this the stream to write to
value char the value to write
return void

Write() public static method

Writes the supplied string to a Stream in UTF8 encoding.
public static Write ( this stream, decimal value ) : void
stream this
value decimal
return void

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, double value ) : void
stream this the stream to write to
value double the value to write
return void

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, float value ) : void
stream this the stream to write to
value float the value to write
return void

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, int value ) : void
stream this the stream to write to
value int the value to write
return void

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, long value ) : void
stream this the stream to write to
value long the value to write
return void

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, sbyte value ) : void
stream this the stream to write to
value sbyte the value to write
return void

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, short value ) : void
stream this the stream to write to
value short the value to write
return void

Write() public static method

Writes the supplied string to a Stream in UTF8 encoding.
public static Write ( this stream, string value ) : void
stream this
value string
return void

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, uint value ) : void
stream this the stream to write to
value uint the value to write
return void

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, ulong value ) : void
stream this the stream to write to
value ulong the value to write
return void

Write() public static method

Writes the supplied value to stream in little endian format.
public static Write ( this stream, ushort value ) : void
stream this the stream to write to
value ushort the value to write
return void

WriteCollection() public static method

Writes the supplied Collection to a Stream.
public static WriteCollection ( this stream, ICollection collection ) : void
stream this
collection ICollection
return void

WriteCollection() public static method

Writes the supplied Collection to a Stream.
public static WriteCollection ( this stream, ICollection collection ) : void
stream this
collection ICollection
return void

WriteNullable() public static method

Writes the supplied string to a Stream in UTF8 encoding with a prefix if the value is null
public static WriteNullable ( this stream, string value ) : void
stream this
value string
return void

WriteWithLength() public static method

Writes the supplied value to stream along with prefixing the length so it can be properly read as a unit.
public static WriteWithLength ( this stream, byte value ) : void
stream this the stream to write to
value byte the value to write
return void