Class BinaryReaderExtensions
Provides extension methods for IReader.
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Serialization
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
public static class BinaryReaderExtensions
Methods
ReadByteArray(BinaryReader)
Reads an array of bytes from the reader of a binary stream.
Declaration
public static byte[] ReadByteArray(this BinaryReader reader)
Parameters
Type | Name | Description |
---|---|---|
BinaryReader | reader | The reader of the binary stream. |
Returns
Type | Description |
---|---|
Byte[] | The byte array constructed from the binary stream. |
ReadGamma(IReader)
Reads a Gamma distribution from the reader of a binary stream.
Declaration
public static Gamma ReadGamma(this IReader reader)
Parameters
Type | Name | Description |
---|---|---|
IReader | reader | The reader of the binary stream. |
Returns
Type | Description |
---|---|
Gamma | The Gamma distribution constructed from the binary stream. |
ReadGammaArray(IReader)
Reads an array of Gamma distributions from the reader of a binary stream.
Declaration
public static DistributionStructArray<Gamma, double> ReadGammaArray(this IReader reader)
Parameters
Type | Name | Description |
---|---|---|
IReader | reader | The reader of the binary stream. |
Returns
Type | Description |
---|---|
DistributionStructArray<Gamma, Double> | The array of Gamma distributions constructed from the binary stream. |
ReadGaussian(IReader)
Reads a Gaussian distribution from the reader of a binary stream.
Declaration
public static Gaussian ReadGaussian(this IReader reader)
Parameters
Type | Name | Description |
---|---|---|
IReader | reader | The reader of the binary stream. |
Returns
Type | Description |
---|---|
Gaussian | The Gaussian distribution constructed from the binary stream. |
ReadGaussianArray(IReader)
Reads an array of Gaussian distributions from the reader of a binary stream.
Declaration
public static DistributionStructArray<Gaussian, double> ReadGaussianArray(this IReader reader)
Parameters
Type | Name | Description |
---|---|---|
IReader | reader | The reader of the binary stream. |
Returns
Type | Description |
---|---|
DistributionStructArray<Gaussian, Double> | The array of Gaussian distributions constructed from the binary stream. |
ReadGaussianMatrix(IReader)
Reads a jagged array of Gaussian distributions from the reader of a binary stream.
Declaration
public static DistributionRefArray<DistributionStructArray<Gaussian, double>, double[]> ReadGaussianMatrix(this IReader reader)
Parameters
Type | Name | Description |
---|---|---|
IReader | reader | The reader of the binary stream. |
Returns
Type | Description |
---|---|
DistributionRefArray<DistributionStructArray<Gaussian, Double>, Double[]> | The jagged array of Gaussian distributions constructed from the binary stream. |
ReadGuid(BinaryReader)
Reads a Guid from the reader of a binary stream.
Declaration
public static Guid ReadGuid(this BinaryReader reader)
Parameters
Type | Name | Description |
---|---|---|
BinaryReader | reader | The reader of the binary stream. |
Returns
Type | Description |
---|---|
Guid | The Guid constructed from the binary stream. |
ReadInt32Array(IReader)
Reads an array of 4-byte signed integers from the reader of a binary stream.
Declaration
public static int[] ReadInt32Array(this IReader reader)
Parameters
Type | Name | Description |
---|---|---|
IReader | reader | The reader of the binary stream. |
Returns
Type | Description |
---|---|
Int32[] | The integer array constructed from the binary stream. |
ReadObject<T>(BinaryReader)
Reads an object from the reader of a binary stream.
Declaration
public static T ReadObject<T>(this BinaryReader reader)
Parameters
Type | Name | Description |
---|---|---|
BinaryReader | reader | The reader of the binary stream. |
Returns
Type | Description |
---|---|
T | The object constructed from the binary stream. |
Type Parameters
Name | Description |
---|---|
T |
ReadSerializationVersion(IReader, Int32, String)
Gets the serialization version from a reader of a binary stream and throws a SerializationException with
the specified message if the version is less than 1 or greater than maxPermittedSerializationVersion
.
Declaration
public static int ReadSerializationVersion(this IReader reader, int maxPermittedSerializationVersion, string exceptionMessage = null)
Parameters
Type | Name | Description |
---|---|---|
IReader | reader | The reader to deserialize the version from. |
Int32 | maxPermittedSerializationVersion | The maximum allowed serialization version. |
String | exceptionMessage | An optional message for the SerializationException. |
Returns
Type | Description |
---|---|
Int32 | The deserialized version. |
Exceptions
Type | Condition |
---|---|
SerializationException | If the deserialized version is less than 1 or greater than |
VerifySerializationGuid(IReader, Guid, String)
Declaration
public static void VerifySerializationGuid(this IReader reader, Guid expectedSerializationGuid, string exceptionMessage = null)
Parameters
Type | Name | Description |
---|---|---|
IReader | reader | The reader to deserialize the Guid from. |
Guid | expectedSerializationGuid | The expected Guid. |
String | exceptionMessage | An optional message for the SerializationException. |
Exceptions
Type | Condition |
---|---|
SerializationException | If the deserialized Guid is invalid. |