CommandMessenger.BinaryConverter Class Reference

## Static Public Member Functions

static string | ToString (Single value)
| Convert a float into a string representation. More...
static string | ToString (Double value)
| Convert a Double into a string representation. More...
static string | ToString (int value)
| Convert an int into a string representation. More...
static string | ToString (uint value)
| Convert an unsigned int into a string representation. More...
static string | ToString (short value)
| Convert a short into a string representation. More...
static string | ToString (ushort value)
| Convert an unsigned an unsigned short into a string representation. More...
static string | ToString (byte value)
| Convert a byte into a string representation. More...
static Single | ToFloat (String value)
| Converts a string to a float. More...
static Double | ToDouble (String value)
| Converts a string representation to a double. More...
static Int32 | ToInt32 (String value)
| Converts a string representation to an int 32. More...
static UInt32 | ToUInt32 (String value)
| Converts a string representation to a u int 32. More...
static UInt16 | ToUInt16 (String value)
| Converts a string representation to a u int 16. More...
static Int16 | ToInt16 (String value)
| Converts a string representation to an int 16. More...
static byte | ToByte (String value)
| Converts a string representation to a byte. More...
static byte[] | EscapedStringToBytes (String value)
| Converts an escaped string to a bytes array. More...

## Properties

Encoding StringEncoder | set
| Sets the string encoder. More...

## Member Function Documentation

static byte [] CommandMessenger.BinaryConverter.EscapedStringToBytes | ( | String | value | ) |

inlinestatic

Converts an escaped string to a bytes array.

Parameters

  value | The value to be converted.

Returns
  input value as an escaped string.

Referenced by CommandMessenger.BinaryConverter.ToByte(), CommandMessenger.BinaryConverter.ToDouble(), CommandMessenger.BinaryConverter.ToFloat(), CommandMessenger.BinaryConverter.ToInt16(), CommandMessenger.BinaryConverter.ToInt32(), CommandMessenger.BinaryConverter.ToUInt16(), and CommandMessenger.BinaryConverter.ToUInt32().

{
try
{
string unEscapedValue = Escaping.Unescape(value);
return _stringEncoder.GetBytes(unEscapedValue);
}
catch (Exception)
{
return null;
}
}

static byte CommandMessenger.BinaryConverter.ToByte | ( | String | value | ) |

inlinestatic

Converts a string representation to a byte.

Parameters

  value | The value to be converted.

Returns
  Input string as a byte?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

{
try
{
byte[] bytes = EscapedStringToBytes(value);
return bytes[0];
}
catch (Exception)
{
return null;
}
}
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static Double CommandMessenger.BinaryConverter.ToDouble | ( | String | value | ) |

inlinestatic

Converts a string representation to a double.

Parameters

  value | The value to be converted.

Returns
  Input string as a Double?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

{
try
{
byte[] bytes = EscapedStringToBytes(value);
return BitConverter.ToDouble(bytes, 0);
}
catch (Exception)
{
return null;
}
}
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static Single CommandMessenger.BinaryConverter.ToFloat | ( | String | value | ) |

inlinestatic

Converts a string to a float.

Parameters

  value | The value to be converted.

Returns
  Input string as a Single?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

{
try
{
byte[] bytes = EscapedStringToBytes(value);
return BitConverter.ToSingle(bytes, 0);
}
catch (Exception)
{
return null;
}
}
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static Int16 CommandMessenger.BinaryConverter.ToInt16 | ( | String | value | ) |

inlinestatic

Converts a string representation to an int 16.

Parameters

  value | The value to be converted.

Returns
  This object as an Int16?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

{
try
{
byte[] bytes = EscapedStringToBytes(value);
return BitConverter.ToInt16(bytes, 0);
}
catch (Exception)
{
return null;
}
}
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static Int32 CommandMessenger.BinaryConverter.ToInt32 | ( | String | value | ) |

inlinestatic

Converts a string representation to an int 32.

Parameters

  value | The value to be converted.

Returns
  This object as an Int32?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

{
try
{
byte[] bytes = EscapedStringToBytes(value);
return BitConverter.ToInt32(bytes, 0);
}
catch (Exception)
{
return null;
}
}
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static string CommandMessenger.BinaryConverter.ToString | ( | Single | value | ) |

inlinestatic

Convert a float into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

{
try
{
byte[] byteArray = BitConverter.GetBytes(value);
return BytesToEscapedString(byteArray);
}
catch (Exception)
{
return null;
}
}

static string CommandMessenger.BinaryConverter.ToString | ( | Double | value | ) |

inlinestatic

Convert a Double into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

{
try
{
byte[] byteArray = BitConverter.GetBytes(value);
return BytesToEscapedString(byteArray);
}
catch (Exception)
{
return null;
}
}

static string CommandMessenger.BinaryConverter.ToString | ( | int | value | ) |

inlinestatic

Convert an int into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

{
try
{
byte[] byteArray = BitConverter.GetBytes(value);
return BytesToEscapedString(byteArray);
}
catch (Exception)
{
return null;
}
}

static string CommandMessenger.BinaryConverter.ToString | ( | uint | value | ) |

inlinestatic

Convert an unsigned int into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

{
try
{
byte[] byteArray = BitConverter.GetBytes(value);
return BytesToEscapedString(byteArray);
}
catch (Exception)
{
return null;
}
}

static string CommandMessenger.BinaryConverter.ToString | ( | short | value | ) |

inlinestatic

Convert a short into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

{
try
{
byte[] byteArray = BitConverter.GetBytes(value);
return BytesToEscapedString(byteArray);
}
catch (Exception)
{
return null;
}
}

static string CommandMessenger.BinaryConverter.ToString | ( | ushort | value | ) |

inlinestatic

Convert an unsigned an unsigned short into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

{
try
{
byte[] byteArray = BitConverter.GetBytes(value);
return BytesToEscapedString(byteArray);
}
catch (Exception)
{
return null;
}
}

static string CommandMessenger.BinaryConverter.ToString | ( | byte | value | ) |

inlinestatic

Convert a byte into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

{
try
{
return BytesToEscapedString(new byte[] {value});
}
catch (Exception)
{
return null;
}
}

static UInt16 CommandMessenger.BinaryConverter.ToUInt16 | ( | String | value | ) |

inlinestatic

Converts a string representation to a u int 16.

Parameters

  value | The value to be converted.

Returns
  Input string as a UInt16?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

{
try
{
byte[] bytes = EscapedStringToBytes(value);
return BitConverter.ToUInt16(bytes, 0);
}
catch (Exception)
{
return null;
}
}
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static UInt32 CommandMessenger.BinaryConverter.ToUInt32 | ( | String | value | ) |

inlinestatic

Converts a string representation to a u int 32.

Parameters

  value | The value to be converted.

Returns
  Input string as a UInt32?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

{
try
{
byte[] bytes = EscapedStringToBytes(value);
return BitConverter.ToUInt32(bytes, 0);
}
catch (Exception)
{
return null;
}
}
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

## Property Documentation

Encoding StringEncoder CommandMessenger.BinaryConverter.set

Sets the string encoder.

The string encoder.

The documentation for this class was generated from the following file:

- D:/My Documents/Github/Arduino-Code-and-Libraries/Libraries/CmdMessenger/CSharp/CommandMessenger/BinaryConverter.cs