Show / Hide Table of Contents

Class Convertible

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

Inheritance
Object
Convertible
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class Convertible

Fields

| Improve this Doc View Source

NullValue

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

Declaration
public const int NullValue = 0
Field Value
Type Description
Int32

Methods

| Improve this Doc View Source

GetBytes(Boolean, Action<EndianOptions>)

Returns the specified Boolean as a byte[].

Declaration
public static byte[] GetBytes(bool input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
Boolean input

The Boolean to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(Byte, Action<EndianOptions>)

Returns the specified Byte as a byte[].

Declaration
public static byte[] GetBytes(byte input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
Byte input

The Byte to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(Char, Action<EndianOptions>)

Returns the specified Char as a byte[].

Declaration
public static byte[] GetBytes(char input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
Char input

The Char to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

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

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

Declaration
public static byte[] GetBytes(IEnumerable<IConvertible> input, Action<ConvertibleOptions> setup = null)
Parameters
Type Name Description
IEnumerable<IConvertible> input

The IEnumerable<T> sequence to convert.

Action<ConvertibleOptions> setup

The ConvertibleOptions which may be configured.

Returns
Type Description
Byte[]

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

| Improve this Doc View Source

GetBytes(DateTime)

Returns the specified DateTime as a byte[].

Declaration
public static byte[] GetBytes(DateTime input)
Parameters
Type Name Description
DateTime input

The DateTime to convert.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(DBNull)

Returns the specified DBNull as a byte[].

Declaration
public static byte[] GetBytes(DBNull input)
Parameters
Type Name Description
DBNull input

The DBNull to convert.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(Decimal)

Returns the specified Decimal as a byte[].

Declaration
public static byte[] GetBytes(decimal input)
Parameters
Type Name Description
Decimal input

The Decimal to convert.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(Double, Action<EndianOptions>)

Returns the specified Double as a byte[].

Declaration
public static byte[] GetBytes(double input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
Double input

The Double to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(Enum, Action<EndianOptions>)

Returns the specified Enum as a byte[].

Declaration
public static byte[] GetBytes(Enum input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
Enum input

The Enum to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(IConvertible, Action<ConvertibleOptions>)

Returns the specified IConvertible as a byte[].

Declaration
public static byte[] GetBytes(IConvertible input, Action<ConvertibleOptions> setup = null)
Parameters
Type Name Description
IConvertible input

The IConvertible implementation to convert.

Action<ConvertibleOptions> setup

The ConvertibleOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

Exceptions
Type Condition
ArgumentOutOfRangeException

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

| Improve this Doc View Source

GetBytes(Int16, Action<EndianOptions>)

Returns the specified Int16 as a byte[].

Declaration
public static byte[] GetBytes(short input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
Int16 input

The Int16 to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(Int32, Action<EndianOptions>)

Returns the specified Int32 as a byte[].

Declaration
public static byte[] GetBytes(int input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
Int32 input

The Int32 to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(Int64, Action<EndianOptions>)

Returns the specified Int64 as a byte[].

Declaration
public static byte[] GetBytes(long input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
Int64 input

The Int64 to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(SByte, Action<EndianOptions>)

Returns the specified SByte as a byte[].

Declaration
public static byte[] GetBytes(sbyte input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
SByte input

The SByte to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(Single, Action<EndianOptions>)

Returns the specified Single as a byte[].

Declaration
public static byte[] GetBytes(float input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
Single input

The Single to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(String, Action<EncodingOptions>)

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

Declaration
public static byte[] GetBytes(string input, Action<EncodingOptions> setup = null)
Parameters
Type Name Description
String input

The String to convert.

Action<EncodingOptions> setup

The EncodingOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

Remarks

IEncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.

Exceptions
Type Condition
ArgumentNullException

input cannot be null.

InvalidEnumArgumentException

setup was initialized with an invalid Preamble.

| Improve this Doc View Source

GetBytes(UInt16, Action<EndianOptions>)

Returns the specified UInt16 as a byte[].

Declaration
public static byte[] GetBytes(ushort input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
UInt16 input

The UInt16 to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(UInt32, Action<EndianOptions>)

Returns the specified UInt32 as a byte[].

Declaration
public static byte[] GetBytes(uint input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
UInt32 input

The UInt32 to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

GetBytes(UInt64, Action<EndianOptions>)

Returns the specified UInt64 as a byte[].

Declaration
public static byte[] GetBytes(ulong input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
UInt64 input

The UInt64 to convert.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

A byte[] that is equivalent to input.

| Improve this Doc View Source

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

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

Declaration
public static void RegisterConvertible<T>(Func<T, byte[]> converter)

    where T : IConvertible
Parameters
Type Name Description
Func<T, Byte[]> converter

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

Type Parameters
Name Description
T

The type of the IConvertible implementation to use.

Exceptions
Type Condition
ArgumentNullException

converter cannot be null.

| Improve this Doc View Source

ReverseBits16(UInt16)

Reverse the bits of the specified input.

Declaration
public static ushort ReverseBits16(ushort input)
Parameters
Type Name Description
UInt16 input

The unsigned 16-bit integer to reverse bits on.

Returns
Type Description
UInt16

A UInt16 with the bits reversed.

| Improve this Doc View Source

ReverseBits32(UInt32)

Reverse the bits of the specified input.

Declaration
public static uint ReverseBits32(uint input)
Parameters
Type Name Description
UInt32 input

The unsigned 32-bit integer to reverse bits on.

Returns
Type Description
UInt32

A UInt32 with the bits reversed.

| Improve this Doc View Source

ReverseBits64(UInt64)

Reverse the bits of the specified input.

Declaration
public static ulong ReverseBits64(ulong input)
Parameters
Type Name Description
UInt64 input

The unsigned 64-bit integer to reverse bits on.

Returns
Type Description
UInt64

A UInt64 with the bits reversed.

| Improve this Doc View Source

ReverseBits8(Byte)

Reverse the bits of the specified input.

Declaration
public static byte ReverseBits8(byte input)
Parameters
Type Name Description
Byte input

The unsigned 8-bit integer to reverse bits on.

Returns
Type Description
Byte

A Byte with the bits reversed.

| Improve this Doc View Source

ReverseEndianness(Byte[], Action<EndianOptions>)

Reverse the endianness of the specified input.

Declaration
public static byte[] ReverseEndianness(byte[] input, Action<EndianOptions> setup = null)
Parameters
Type Name Description
Byte[] input

The byte[] to reverse.

Action<EndianOptions> setup

The EndianOptions which may be configured.

Returns
Type Description
Byte[]

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

| Improve this Doc View Source

ToString(Byte[], Action<EncodingOptions>)

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

Declaration
public static string ToString(byte[] input, Action<EncodingOptions> setup = null)
Parameters
Type Name Description
Byte[] input

The byte[] to convert.

Action<EncodingOptions> setup

The EncodingOptions which may be configured.

Returns
Type Description
String

A String that is equivalent to input.

Remarks

IEncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.

Exceptions
Type Condition
ArgumentNullException

input cannot be null.

InvalidEnumArgumentException

setup was initialized with an invalid Preamble.

  • Improve this Doc
  • View Source
In This Article
Back to top Copyright 2008-2022 Geekle. All rights reserved. Code with passion and love; deploy with confidence. 👨‍💻️🔥❤️🚀😎
Generated by DocFX