C# Class ME3Explorer.EndianBitConverter

Converts base data types to an array of bytes, and an array of bytes to base data types. All info taken from the meta data of System.BitConverter. This implementation allows for Endianness consideration.
ファイルを表示 Open project: ME3Explorer/ME3Explorer

Public Methods

Method Description
GetBytes ( bool value ) : byte[]

Returns the specified Boolean value as an array of bytes. Parameters: value: A Boolean value. Returns: An array of bytes with length 1.

GetBytes ( char value ) : byte[]

Returns the specified Unicode character value as an array of bytes. Parameters: value: A character to convert. Returns: An array of bytes with length 2.

GetBytes ( double value ) : byte[]

Returns the specified double-precision floating point value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 8.

GetBytes ( float value ) : byte[]

Returns the specified single-precision floating point value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 4.

GetBytes ( int value ) : byte[]

Returns the specified 32-bit signed integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 4.

GetBytes ( long value ) : byte[]

Returns the specified 64-bit signed integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 8.

GetBytes ( short value ) : byte[]

Returns the specified 16-bit signed integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 2.

GetBytes ( uint value ) : byte[]

Returns the specified 32-bit unsigned integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 4.

GetBytes ( ulong value ) : byte[]

Returns the specified 64-bit unsigned integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 8.

GetBytes ( ushort value ) : byte[]

Returns the specified 16-bit unsigned integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 2.

ToBoolean ( byte value, int startIndex ) : bool

Returns a Boolean value converted from one byte at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: true if the byte at startIndex in value is nonzero; otherwise, false. Exceptions: System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.

ToChar ( byte value, int startIndex ) : char

Returns a Unicode character converted from two bytes at a specified position in a byte array. Parameters: value: An array. startIndex: The starting position within value. Returns: A character formed by two bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex equals the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.

ToDouble ( byte value, int startIndex ) : double

Returns a double-precision floating point number converted from eight bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A double precision floating point number formed by eight bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 7, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.

ToInt16 ( byte value, int startIndex ) : short

Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A 16-bit signed integer formed by two bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex equals the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.

ToInt32 ( byte value, int startIndex ) : int

Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A 32-bit signed integer formed by four bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 3, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.

ToInt64 ( byte value, int startIndex ) : long

Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A 64-bit signed integer formed by eight bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 7, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.

ToSingle ( byte value, int startIndex ) : float

Returns a single-precision floating point number converted from four bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A single-precision floating point number formed by four bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 3, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.

ToString ( byte value ) : string

Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string representation. Parameters: value: An array of bytes. Returns: A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A". Exceptions: System.ArgumentNullException: value is null.

ToString ( byte value, int startIndex ) : string

Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in a subarray of value; for example, "7F-2C-4A". Exceptions: System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.

ToString ( byte value, int startIndex, int length ) : string

Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation. Parameters: value: An array of bytes. startIndex: The starting position within value. length: The number of array elements in value to convert. Returns: A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in a subarray of value; for example, "7F-2C-4A". Exceptions: System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex or length is less than zero. -or- startIndex is greater than zero and is greater than or equal to the length of value. System.ArgumentException: The combination of startIndex and length does not specify a position within value; that is, the startIndex parameter is greater than the length of value minus the length parameter.

ToUInt16 ( byte value, int startIndex ) : ushort

Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array. Parameters: value: The array of bytes. startIndex: The starting position within value. Returns: A 16-bit unsigned integer formed by two bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex equals the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.

ToUInt32 ( byte value, int startIndex ) : uint

Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A 32-bit unsigned integer formed by four bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 3, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.

ToUInt64 ( byte value, int startIndex ) : ulong

Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A 64-bit unsigned integer formed by the eight bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 7, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.

Private Methods

Method Description
EndianBitConverter ( ) : System

Method Details

GetBytes() public static method

Returns the specified Boolean value as an array of bytes. Parameters: value: A Boolean value. Returns: An array of bytes with length 1.
public static GetBytes ( bool value ) : byte[]
value bool
return byte[]

GetBytes() public static method

Returns the specified Unicode character value as an array of bytes. Parameters: value: A character to convert. Returns: An array of bytes with length 2.
public static GetBytes ( char value ) : byte[]
value char
return byte[]

GetBytes() public static method

Returns the specified double-precision floating point value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 8.
public static GetBytes ( double value ) : byte[]
value double
return byte[]

GetBytes() public static method

Returns the specified single-precision floating point value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 4.
public static GetBytes ( float value ) : byte[]
value float
return byte[]

GetBytes() public static method

Returns the specified 32-bit signed integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 4.
public static GetBytes ( int value ) : byte[]
value int
return byte[]

GetBytes() public static method

Returns the specified 64-bit signed integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 8.
public static GetBytes ( long value ) : byte[]
value long
return byte[]

GetBytes() public static method

Returns the specified 16-bit signed integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 2.
public static GetBytes ( short value ) : byte[]
value short
return byte[]

GetBytes() public static method

Returns the specified 32-bit unsigned integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 4.
public static GetBytes ( uint value ) : byte[]
value uint
return byte[]

GetBytes() public static method

Returns the specified 64-bit unsigned integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 8.
public static GetBytes ( ulong value ) : byte[]
value ulong
return byte[]

GetBytes() public static method

Returns the specified 16-bit unsigned integer value as an array of bytes. Parameters: value: The number to convert. Returns: An array of bytes with length 2.
public static GetBytes ( ushort value ) : byte[]
value ushort
return byte[]

ToBoolean() public static method

Returns a Boolean value converted from one byte at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: true if the byte at startIndex in value is nonzero; otherwise, false. Exceptions: System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.
public static ToBoolean ( byte value, int startIndex ) : bool
value byte
startIndex int
return bool

ToChar() public static method

Returns a Unicode character converted from two bytes at a specified position in a byte array. Parameters: value: An array. startIndex: The starting position within value. Returns: A character formed by two bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex equals the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.
public static ToChar ( byte value, int startIndex ) : char
value byte
startIndex int
return char

ToDouble() public static method

Returns a double-precision floating point number converted from eight bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A double precision floating point number formed by eight bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 7, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.
public static ToDouble ( byte value, int startIndex ) : double
value byte
startIndex int
return double

ToInt16() public static method

Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A 16-bit signed integer formed by two bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex equals the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.
public static ToInt16 ( byte value, int startIndex ) : short
value byte
startIndex int
return short

ToInt32() public static method

Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A 32-bit signed integer formed by four bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 3, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.
public static ToInt32 ( byte value, int startIndex ) : int
value byte
startIndex int
return int

ToInt64() public static method

Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A 64-bit signed integer formed by eight bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 7, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.
public static ToInt64 ( byte value, int startIndex ) : long
value byte
startIndex int
return long

ToSingle() public static method

Returns a single-precision floating point number converted from four bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A single-precision floating point number formed by four bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 3, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.
public static ToSingle ( byte value, int startIndex ) : float
value byte
startIndex int
return float

ToString() public static method

Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string representation. Parameters: value: An array of bytes. Returns: A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A". Exceptions: System.ArgumentNullException: value is null.
public static ToString ( byte value ) : string
value byte
return string

ToString() public static method

Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in a subarray of value; for example, "7F-2C-4A". Exceptions: System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.
public static ToString ( byte value, int startIndex ) : string
value byte
startIndex int
return string

ToString() public static method

Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation. Parameters: value: An array of bytes. startIndex: The starting position within value. length: The number of array elements in value to convert. Returns: A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in a subarray of value; for example, "7F-2C-4A". Exceptions: System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex or length is less than zero. -or- startIndex is greater than zero and is greater than or equal to the length of value. System.ArgumentException: The combination of startIndex and length does not specify a position within value; that is, the startIndex parameter is greater than the length of value minus the length parameter.
public static ToString ( byte value, int startIndex, int length ) : string
value byte
startIndex int
length int
return string

ToUInt16() public static method

Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array. Parameters: value: The array of bytes. startIndex: The starting position within value. Returns: A 16-bit unsigned integer formed by two bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex equals the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.
public static ToUInt16 ( byte value, int startIndex ) : ushort
value byte
startIndex int
return ushort

ToUInt32() public static method

Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A 32-bit unsigned integer formed by four bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 3, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.
public static ToUInt32 ( byte value, int startIndex ) : uint
value byte
startIndex int
return uint

ToUInt64() public static method

Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array. Parameters: value: An array of bytes. startIndex: The starting position within value. Returns: A 64-bit unsigned integer formed by the eight bytes beginning at startIndex. Exceptions: System.ArgumentException: startIndex is greater than or equal to the length of value minus 7, and is less than or equal to the length of value minus 1. System.ArgumentNullException: value is null. System.ArgumentOutOfRangeException: startIndex is less than zero or greater than the length of value minus 1.
public static ToUInt64 ( byte value, int startIndex ) : ulong
value byte
startIndex int
return ulong