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

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:

Return Value:

An IByteReader object.

Exceptions:

ToByteReader

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:

Return Value:

An IByteReader object.

Exceptions:

ToByteReader

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:

Return Value:

An IByteReader object.

Exceptions:

ToReader

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:

Return Value:

A byte reader wrapping the byte array.

Exceptions:

ToReader

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:

Return Value:

A byte reader wrapping the byte array.

Exceptions:

ToReader

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:

Return Value:

A byte reader wrapping the input stream.

Exceptions:

ToWriter

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:

Return Value:

A writer that wraps the given stream.

Exceptions:

ToWriter

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:

Return Value:

A byte writer that wraps the given output stream.

Exceptions:

Back to Encoding start page.