Table of Contents

Class Convertible

Namespace
Cuemon
Assembly
Cuemon.Core.dll

Provides a set of static methods, suitable for verifying integrity of data, that convert System.IConvertible implementations to and from a sequence of bytes.

public static class Convertible
Inheritance
Object
Convertible

Fields

NullValue

A representation for a null value when converting to a byte[].

public const int NullValue = 0

Field Value

Int32

Methods

GetBytes(Boolean, Action<EndianOptions>)

Returns the specified System.Boolean as a byte[].

public static byte[] GetBytes(bool input, Action<EndianOptions> setup = null)

Parameters

input Boolean

The System.Boolean to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(Byte, Action<EndianOptions>)

Returns the specified System.Byte as a byte[].

public static byte[] GetBytes(byte input, Action<EndianOptions> setup = null)

Parameters

input Byte

The System.Byte to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(Char, Action<EndianOptions>)

Returns the specified System.Char as a byte[].

public static byte[] GetBytes(char input, Action<EndianOptions> setup = null)

Parameters

input Char

The System.Char to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(IEnumerable<IConvertible>, Action<ConvertibleOptions>)

Returns the specified sequence of System.IConvertible as an aggregated byte[].

public static byte[] GetBytes(IEnumerable<IConvertible> input, Action<ConvertibleOptions> setup = null)

Parameters

input IEnumerable<IConvertible>

The System.Collections.Generic.IEnumerable<T> sequence to convert.

setup Action<ConvertibleOptions>

The ConvertibleOptions which may be configured.

Returns

Byte[]

An aggregated byte[] that is otherwise equivalent to input.

GetBytes(DateTime)

Returns the specified System.DateTime as a byte[].

public static byte[] GetBytes(DateTime input)

Parameters

input DateTime

The System.DateTime to convert.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(DBNull)

Returns the specified System.DBNull as a byte[].

public static byte[] GetBytes(DBNull input)

Parameters

input DBNull

The System.DBNull to convert.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(Decimal)

Returns the specified System.Decimal as a byte[].

public static byte[] GetBytes(decimal input)

Parameters

input Decimal

The System.Decimal to convert.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(Double, Action<EndianOptions>)

Returns the specified System.Double as a byte[].

public static byte[] GetBytes(double input, Action<EndianOptions> setup = null)

Parameters

input Double

The System.Double to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(Enum, Action<EndianOptions>)

Returns the specified System.Enum as a byte[].

public static byte[] GetBytes(Enum input, Action<EndianOptions> setup = null)

Parameters

input Enum

The System.Enum to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(IConvertible, Action<ConvertibleOptions>)

Returns the specified System.IConvertible as a byte[].

public static byte[] GetBytes(IConvertible input, Action<ConvertibleOptions> setup = null)

Parameters

input IConvertible

The System.IConvertible implementation to convert.

setup Action<ConvertibleOptions>

The ConvertibleOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

Exceptions

ArgumentOutOfRangeException

input is an unknown implementation of System.IConvertible; please use RegisterConvertible to make a custom implementation globally known -or- use setup to add a custom implementation using ConvertibleOptions.Converters..Add.

GetBytes(Int16, Action<EndianOptions>)

Returns the specified System.Int16 as a byte[].

public static byte[] GetBytes(short input, Action<EndianOptions> setup = null)

Parameters

input Int16

The System.Int16 to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(Int32, Action<EndianOptions>)

Returns the specified System.Int32 as a byte[].

public static byte[] GetBytes(int input, Action<EndianOptions> setup = null)

Parameters

input Int32

The System.Int32 to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(Int64, Action<EndianOptions>)

Returns the specified System.Int64 as a byte[].

public static byte[] GetBytes(long input, Action<EndianOptions> setup = null)

Parameters

input Int64

The System.Int64 to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(SByte, Action<EndianOptions>)

Returns the specified System.SByte as a byte[].

public static byte[] GetBytes(sbyte input, Action<EndianOptions> setup = null)

Parameters

input SByte

The System.SByte to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(Single, Action<EndianOptions>)

Returns the specified System.Single as a byte[].

public static byte[] GetBytes(float input, Action<EndianOptions> setup = null)

Parameters

input Single

The System.Single to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(String, Action<EncodingOptions>)

Returns the specified System.String as its equivalent byte[] representation.

public static byte[] GetBytes(string input, Action<EncodingOptions> setup = null)

Parameters

input String

The System.String to convert.

setup Action<EncodingOptions>

The EncodingOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

Remarks

Exceptions

System.ArgumentNullException

input cannot be null.

System.ComponentModel.InvalidEnumArgumentException

setup was initialized with an invalid Preamble.

GetBytes(UInt16, Action<EndianOptions>)

Returns the specified System.UInt16 as a byte[].

public static byte[] GetBytes(ushort input, Action<EndianOptions> setup = null)

Parameters

input UInt16

The System.UInt16 to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(UInt32, Action<EndianOptions>)

Returns the specified System.UInt32 as a byte[].

public static byte[] GetBytes(uint input, Action<EndianOptions> setup = null)

Parameters

input UInt32

The System.UInt32 to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

GetBytes(UInt64, Action<EndianOptions>)

Returns the specified System.UInt64 as a byte[].

public static byte[] GetBytes(ulong input, Action<EndianOptions> setup = null)

Parameters

input UInt64

The System.UInt64 to convert.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that is equivalent to input.

RegisterConvertible<T>(Func<T, Byte[]>)

Registers the specified System.IConvertible implementation of T to make it globally known.

public static void RegisterConvertible<T>(Func<T, byte[]> converter)
    where T : IConvertible

Parameters

converter Func<T, Byte[]>

The function delegate that converts an System.IConvertible implementation to its equivalent byte[].

Type Parameters

T

The type of the System.IConvertible implementation to use.

Exceptions

System.ArgumentNullException

converter cannot be null.

ReverseBits16(UInt16)

Reverse the bits of the specified input.

public static ushort ReverseBits16(ushort input)

Parameters

input UInt16

The unsigned 16-bit integer to reverse bits on.

Returns

UInt16

A System.UInt16 with the bits reversed.

ReverseBits32(UInt32)

Reverse the bits of the specified input.

public static uint ReverseBits32(uint input)

Parameters

input UInt32

The unsigned 32-bit integer to reverse bits on.

Returns

UInt32

A System.UInt32 with the bits reversed.

ReverseBits64(UInt64)

Reverse the bits of the specified input.

public static ulong ReverseBits64(ulong input)

Parameters

input UInt64

The unsigned 64-bit integer to reverse bits on.

Returns

UInt64

A System.UInt64 with the bits reversed.

ReverseBits8(Byte)

Reverse the bits of the specified input.

public static byte ReverseBits8(byte input)

Parameters

input Byte

The unsigned 8-bit integer to reverse bits on.

Returns

Byte

A System.Byte with the bits reversed.

ReverseEndianness(Byte[], Action<EndianOptions>)

Reverse the endianness of the specified input.

public static byte[] ReverseEndianness(byte[] input, Action<EndianOptions> setup = null)

Parameters

input Byte[]

The byte[] to reverse.

setup Action<EndianOptions>

The EndianOptions which may be configured.

Returns

Byte[]

A byte[] that, depending on the setup, is either equal or a reversed value of input.

ToString(Byte[], Action<EncodingOptions>)

Returns the specified byte[] as its equivalent System.String representation.

public static string ToString(byte[] input, Action<EncodingOptions> setup = null)

Parameters

input Byte[]

The byte[] to convert.

setup Action<EncodingOptions>

The EncodingOptions which may be configured.

Returns

String

A System.String that is equivalent to input.

Remarks

Exceptions

System.ArgumentNullException

input cannot be null.

System.ComponentModel.InvalidEnumArgumentException

setup was initialized with an invalid Preamble.