Class ParsingUtils
Utility class containing methods to work with several data type conversions.
Inheritance
Inherited Members
Namespace: XBeeLibrary.Core.Utils
Assembly: XBeeLibrary.Core.dll
Syntax
public class ParsingUtils
Fields
BLANK_SPACE_CODE
Declaration
public const string BLANK_SPACE_CODE = "0x20"
Field Value
Type | Description |
---|---|
System.String |
HEXADECIMAL_PREFIX
Declaration
public const string HEXADECIMAL_PREFIX = "0X"
Field Value
Type | Description |
---|---|
System.String |
MXI_EXTENSION
Declaration
public const string MXI_EXTENSION = ".mxi"
Field Value
Type | Description |
---|---|
System.String |
PRO_EXTENSION
Declaration
public const string PRO_EXTENSION = ".pro"
Field Value
Type | Description |
---|---|
System.String |
VALUE_FALSE
Declaration
public const string VALUE_FALSE = "false"
Field Value
Type | Description |
---|---|
System.String |
VALUE_TRUE
Declaration
public const string VALUE_TRUE = "true"
Field Value
Type | Description |
---|---|
System.String |
XML_EXTENSION
Declaration
public const string XML_EXTENSION = ".xml"
Field Value
Type | Description |
---|---|
System.String |
XPRO_EXTENSION
Declaration
public const string XPRO_EXTENSION = ".xpro"
Field Value
Type | Description |
---|---|
System.String |
Methods
ByteArrayToHexString(Byte[])
Converts the given byte array into a hex string.
Declaration
public static string ByteArrayToHexString(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | Byte array to convert to hex string. |
Returns
Type | Description |
---|---|
System.String | Converted byte array to hex string. |
ByteArrayToHexString(Byte[], Int32, Int32)
Converts the given byte array into a hex string.
Declaration
public static string ByteArrayToHexString(byte[] value, int from, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | Byte array to convert to hex string. |
System.Int32 | from | The initial index of the range to be converted, inclusive. |
System.Int32 | length | The number of array elements to be converted. |
Returns
Type | Description |
---|---|
System.String | Converted byte array to hex string. |
ByteArrayToInt(Byte[])
Converts the given byte array (4 bytes length max) into an integer.
Declaration
public static int ByteArrayToInt(byte[] b)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | b | Byte array to convert to integer (4 bytes length max). |
Returns
Type | Description |
---|---|
System.Int32 | Converted integer. |
GetBigInt(String)
Returns the big integer value corresponding to the give hexadecimal value string. The string can come with or without the 0x prefix.
Declaration
public static BigInteger GetBigInt(string hexValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | hexValue | Hex string to convert to big integer. |
Returns
Type | Description |
---|---|
System.Numerics.BigInteger | The big integer value corresponding to the give hexadecimal value
string, or |
HexStringToAscii(String)
Returns the ASCII representation in string format of the given hexadecimal string.
Declaration
public static string HexStringToAscii(string hexString)
Parameters
Type | Name | Description |
---|---|---|
System.String | hexString | The hexadecimal string to convert to ASCII. |
Returns
Type | Description |
---|---|
System.String | The ASCII representation in string format of the given hexadecimal string.
|
HexStringToByteArray(String)
Converts the given hex string into a byte array.
Declaration
public static byte[] HexStringToByteArray(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | Hex string to convert to. |
Returns
Type | Description |
---|---|
System.Byte[] | Byte array of the given hex string. |
HexStringToInt(String)
Retrieves the integer value of the given hexadecimal string. The string can come with or without the 0x prefix.
Declaration
public static int HexStringToInt(string hexValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | hexValue | Hex string to convert to integer. |
Returns
Type | Description |
---|---|
System.Int32 | The integer value of the given hexadecimal string. |
IntegerToHexString(Int32, Int32)
Retrieves the given integer as hexadecimal string.
Declaration
public static string IntegerToHexString(int value, int minBytes)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The integer value to convert to hexadecimal string. |
System.Int32 | minBytes | The minimum number of bytes to be represented. |
Returns
Type | Description |
---|---|
System.String | The integer value as hexadecimal string. |
IntToByteArray(Int32)
Converts the given integer into a byte array.
Declaration
public static byte[] IntToByteArray(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | Integer to convert to. |
Returns
Type | Description |
---|---|
System.Byte[] | Byte array of the given integer (4 bytes length). |
IsHexadecimal(String)
Returns whether or not the given string value can be casted to Integer.
Declaration
public static bool IsHexadecimal(string stringValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | stringValue | The string value to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsInteger(String)
Returns whether or not the given string value can be casted to Integer.
Declaration
public static bool IsInteger(string stringValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | stringValue | The string value to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|