PeterO.DataIO
## PeterO.DataIO
public static class DataIO
Convenience class that contains static methods for wrapping byte arrays and streams into byte readers and byte writers.
Member Summary
[ToByteReader(this byte[])](#ToByteReader_this_byte)
- Deprecated: Use ToReader instead.[ToByteReader(this byte[], int, int)](#ToByteReader_this_byte_int_int)
- Deprecated: Use ToReader instead.[ToByteReader(this System.IO.Stream)](#ToByteReader_this_System_IO_Stream)
- Deprecated: Use ToReader instead.[ToReader(this byte[])](#ToReader_this_byte)
- Wraps a byte array into a byte reader.[ToReader(this byte[], int, int)](#ToReader_this_byte_int_int)
- Wraps a portion of a byte array into a byte reader object.[ToReader(this System.IO.Stream)](#ToReader_this_System_IO_Stream)
- Wraps an input stream into a reader object.[ToWriter(this PeterO.IByteWriter)](#ToWriter_this_PeterO_IByteWriter)
- Wraps a byte writer (one that only implements a ReadByte method) to a writer (one that also implements a three-parameter Read method.[ToWriter(this System.IO.Stream)](#ToWriter_this_System_IO_Stream)
- Wraps an output stream into a writer object.
public static PeterO.IByteReader ToByteReader( this byte[] bytes);
Deprecated. Use ToReader instead.
Wraps a byte array into a byte reader. In the.NET implementation, this method is implemented as an extension method to any object implementing byte[] and can be called as follows: bytes.ToByteReader()
. If the object’s class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.
Parameters:
- bytes: The byte array to wrap into a byte reader.
Return Value:
An IByteReader object.
Exceptions:
- System.ArgumentNullException: The parameter bytes is null.
public static PeterO.IByteReader ToByteReader( this byte[] bytes, int offset, int length);
Deprecated. Use ToReader instead.
Wraps a portion of a byte array into a byte reader. In the.NET implementation, this method is implemented as an extension method to any object implementing byte[] and can be called as follows: bytes.ToByteReader(offset, length)
. If the object’s class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.
Parameters:
-
bytes: The byte array to wrap into a byte reader.
-
offset: An index starting at 0 showing where the desired portion of bytes begins.
-
length: The length, in bytes, of the desired portion of bytes (but not more than bytes ‘s length).
Return Value:
An IByteReader object.
Exceptions:
-
T:System.ArgumentNullException: The parameter bytes is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than bytes ‘s length, or bytes ‘s length minus offset is less than length .
-
System.ArgumentNullException: The parameter bytes is null.
public static PeterO.IByteReader ToByteReader( this System.IO.Stream input);
Deprecated. Use ToReader instead.
Wraps a data stream into a byte reader. In the.NET implementation, this method is implemented as an extension method to any object implementing Stream and can be called as follows: input.ToByteReader()
. If the object’s class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.
Parameters:
- input: The data stream to wrap into a byte reader.
Return Value:
An IByteReader object.
Exceptions:
- System.ArgumentNullException: The parameter input is null.
public static PeterO.IReader ToReader( this byte[] bytes);
Wraps a byte array into a byte reader. The reader will start at the beginning of the byte array. In the.NET implementation, this method is implemented as an extension method to any byte array object and can be called as follows: bytes.ToByteReader()
. If the object’s class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.
Parameters:
- bytes: The byte array to wrap.
Return Value:
A byte reader wrapping the byte array.
Exceptions:
- System.ArgumentNullException: The parameter bytes is null.
public static PeterO.IReader ToReader( this byte[] bytes, int offset, int length);
Wraps a portion of a byte array into a byte reader object. In the.NET implementation, this method is implemented as an extension method to any byte array object and can be called as follows: bytes.ToByteReader(offset, length)
. If the object’s class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.
Parameters:
-
bytes: The byte array to wrap.
-
offset: An index starting at 0 showing where the desired portion of “bytes” begins.
-
length: The length, in bytes, of the desired portion of “bytes” (but not more than “bytes” ‘s length).
Return Value:
A byte reader wrapping the byte array.
Exceptions:
-
T:System.ArgumentNullException: The parameter bytes is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than bytes ‘s length, or bytes ‘s length minus offset is less than length .
-
System.ArgumentNullException: The parameter bytes is null.
public static PeterO.IReader ToReader( this System.IO.Stream input);
Wraps an input stream into a reader object. If an IOException is thrown by the input stream, the reader object throws InvalidOperationException instead. In the.NET implementation, this method is implemented as an extension method to any object implementing Stream and can be called as follows: input.ToByteReader()
. If the object’s class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.
Parameters:
- input: The input stream to wrap.
Return Value:
A byte reader wrapping the input stream.
Exceptions:
- System.ArgumentNullException: The parameter input is null.
public static PeterO.IWriter ToWriter( this PeterO.IByteWriter output);
Wraps a byte writer (one that only implements a ReadByte method) to a writer (one that also implements a three-parameter Read method.) In the.NET implementation, this method is implemented as an extension method to any object implementing IByteWriter and can be called as follows: output.ToWriter()
. If the object’s class already has a ToWriter method with the same parameters, that method takes precedence over this extension method.
Parameters:
- output: A byte stream.
Return Value:
A writer that wraps the given stream.
Exceptions:
- System.ArgumentNullException: The parameter output is null.
public static PeterO.IWriter ToWriter( this System.IO.Stream output);
Wraps an output stream into a writer object. If an IOException is thrown by the input stream, the writer object throws InvalidOperationException instead. In the.NET implementation, this method is implemented as an extension method to any object implementing Stream and can be called as follows: output.ToWriter()
. If the object’s class already has a ToWriter method with the same parameters, that method takes precedence over this extension method.
Parameters:
- output: Output stream to wrap.
Return Value:
A byte writer that wraps the given output stream.
Exceptions:
- System.ArgumentNullException: The parameter output is null.