REFACTOR: Final cleanup of DiscImageChef.Helpers.

This commit is contained in:
2017-12-24 02:46:53 +00:00
parent f9cc6e6918
commit 5bdd1ea0cd
19 changed files with 345 additions and 230 deletions

View File

@@ -32,7 +32,7 @@ namespace DiscImageChef
public static partial class ArrayHelpers public static partial class ArrayHelpers
{ {
/// <summary> /// <summary>
/// Fills an array with the specified value /// Fills an array with the specified value
/// </summary> /// </summary>
/// <param name="destinationArray">Array</param> /// <param name="destinationArray">Array</param>
/// <param name="value">Value</param> /// <param name="value">Value</param>
@@ -44,7 +44,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Fills an array with the contents of the specified array /// Fills an array with the contents of the specified array
/// </summary> /// </summary>
/// <param name="destinationArray">Array</param> /// <param name="destinationArray">Array</param>
/// <param name="value">Value</param> /// <param name="value">Value</param>
@@ -53,7 +53,8 @@ namespace DiscImageChef
{ {
if(destinationArray == null) throw new ArgumentNullException(nameof(destinationArray)); if(destinationArray == null) throw new ArgumentNullException(nameof(destinationArray));
if(value.Length > destinationArray.Length) throw new ArgumentException("Length of value array must not be more than length of destination"); if(value.Length > destinationArray.Length)
throw new ArgumentException("Length of value array must not be more than length of destination");
// set the initial array value // set the initial array value
Array.Copy(value, destinationArray, value.Length); Array.Copy(value, destinationArray, value.Length);
@@ -61,13 +62,14 @@ namespace DiscImageChef
int arrayToFillHalfLength = destinationArray.Length / 2; int arrayToFillHalfLength = destinationArray.Length / 2;
int copyLength; int copyLength;
for(copyLength = value.Length; copyLength < arrayToFillHalfLength; copyLength <<= 1) Array.Copy(destinationArray, 0, destinationArray, copyLength, copyLength); for(copyLength = value.Length; copyLength < arrayToFillHalfLength; copyLength <<= 1)
Array.Copy(destinationArray, 0, destinationArray, copyLength, copyLength);
Array.Copy(destinationArray, 0, destinationArray, copyLength, destinationArray.Length - copyLength); Array.Copy(destinationArray, 0, destinationArray, copyLength, destinationArray.Length - copyLength);
} }
/// <summary> /// <summary>
/// Converts a byte array to its hexadecimal representation /// Converts a byte array to its hexadecimal representation
/// </summary> /// </summary>
/// <param name="array">Byte array</param> /// <param name="array">Byte array</param>
/// <param name="upper"><c>true</c> to use uppercase</param> /// <param name="upper"><c>true</c> to use uppercase</param>

View File

@@ -37,7 +37,7 @@ namespace DiscImageChef
public static partial class ArrayHelpers public static partial class ArrayHelpers
{ {
/// <summary> /// <summary>
/// Checks if an array is null, filled with the NULL byte (0x00) or ASCII whitespace (0x20) /// Checks if an array is null, filled with the NULL byte (0x00) or ASCII whitespace (0x20)
/// </summary> /// </summary>
/// <param name="array">Array</param> /// <param name="array">Array</param>
/// <returns>True if null or whitespace</returns> /// <returns>True if null or whitespace</returns>
@@ -47,7 +47,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Checks if an array is null or filled with the NULL byte (0x00) /// Checks if an array is null or filled with the NULL byte (0x00)
/// </summary> /// </summary>
/// <param name="array">Array</param> /// <param name="array">Array</param>
/// <returns>True if null</returns> /// <returns>True if null</returns>

View File

@@ -36,21 +36,21 @@ using System.Linq;
namespace DiscImageChef namespace DiscImageChef
{ {
/// <summary> /// <summary>
/// Converts base data types to an array of bytes, and an array of bytes to base /// Converts base data types to an array of bytes, and an array of bytes to base
/// data types. /// data types.
/// All info taken from the meta data of System.BitConverter. This implementation /// All info taken from the meta data of System.BitConverter. This implementation
/// allows for Endianness consideration. /// allows for Endianness consideration.
/// </summary> /// </summary>
public static class BigEndianBitConverter public static class BigEndianBitConverter
{ {
/// <summary> /// <summary>
/// Indicates the byte order ("endianess") in which data is stored in this computer /// Indicates the byte order ("endianess") in which data is stored in this computer
/// architecture. /// architecture.
/// </summary> /// </summary>
public static bool IsLittleEndian { get; set; } public static bool IsLittleEndian { get; set; }
/// <summary> /// <summary>
/// Converts the specified double-precision floating point number to a 64-bit signed integer. /// Converts the specified double-precision floating point number to a 64-bit signed integer.
/// </summary> /// </summary>
/// <param name="value">The number to convert.</param> /// <param name="value">The number to convert.</param>
/// <returns>A 64-bit signed integer whose value is equivalent to value.</returns> /// <returns>A 64-bit signed integer whose value is equivalent to value.</returns>
@@ -61,7 +61,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns the specified Boolean value as an array of bytes. /// Returns the specified Boolean value as an array of bytes.
/// </summary> /// </summary>
/// <param name="value">A Boolean value.</param> /// <param name="value">A Boolean value.</param>
/// <returns>An array of bytes with length 1.</returns> /// <returns>An array of bytes with length 1.</returns>
@@ -71,7 +71,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns the specified Unicode character value as an array of bytes. /// Returns the specified Unicode character value as an array of bytes.
/// </summary> /// </summary>
/// <param name="value">A character to convert.</param> /// <param name="value">A character to convert.</param>
/// <returns>An array of bytes with length 2.</returns> /// <returns>An array of bytes with length 2.</returns>
@@ -81,7 +81,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns the specified double-precision floating point value as an array of bytes. /// Returns the specified double-precision floating point value as an array of bytes.
/// </summary> /// </summary>
/// <param name="value">The number to convert.</param> /// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 8.</returns> /// <returns>An array of bytes with length 8.</returns>
@@ -91,7 +91,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns the specified single-precision floating point value as an array of bytes. /// Returns the specified single-precision floating point value as an array of bytes.
/// </summary> /// </summary>
/// <param name="value">The number to convert.</param> /// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 4.</returns> /// <returns>An array of bytes with length 4.</returns>
@@ -101,7 +101,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns the specified 32-bit signed integer value as an array of bytes. /// Returns the specified 32-bit signed integer value as an array of bytes.
/// </summary> /// </summary>
/// <param name="value">The number to convert.</param> /// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 4.</returns> /// <returns>An array of bytes with length 4.</returns>
@@ -111,7 +111,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns the specified 64-bit signed integer value as an array of bytes. /// Returns the specified 64-bit signed integer value as an array of bytes.
/// </summary> /// </summary>
/// <param name="value">The number to convert.</param> /// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 8.</returns> /// <returns>An array of bytes with length 8.</returns>
@@ -121,7 +121,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns the specified 16-bit signed integer value as an array of bytes. /// Returns the specified 16-bit signed integer value as an array of bytes.
/// </summary> /// </summary>
/// <param name="value">The number to convert.</param> /// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 2.</returns> /// <returns>An array of bytes with length 2.</returns>
@@ -131,7 +131,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns the specified 32-bit unsigned integer value as an array of bytes. /// Returns the specified 32-bit unsigned integer value as an array of bytes.
/// </summary> /// </summary>
/// <param name="value">The number to convert.</param> /// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 4.</returns> /// <returns>An array of bytes with length 4.</returns>
@@ -141,7 +141,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns the specified 64-bit unsigned integer value as an array of bytes. /// Returns the specified 64-bit unsigned integer value as an array of bytes.
/// </summary> /// </summary>
/// <param name="value">The number to convert.</param> /// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 8.</returns> /// <returns>An array of bytes with length 8.</returns>
@@ -151,7 +151,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns the specified 16-bit unsigned integer value as an array of bytes. /// Returns the specified 16-bit unsigned integer value as an array of bytes.
/// </summary> /// </summary>
/// <param name="value">The number to convert.</param> /// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 2.</returns> /// <returns>An array of bytes with length 2.</returns>
@@ -161,7 +161,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts the specified 64-bit signed integer to a double-precision floating point number. /// Converts the specified 64-bit signed integer to a double-precision floating point number.
/// </summary> /// </summary>
/// <param name="value">The number to convert.</param> /// <param name="value">The number to convert.</param>
/// <returns>A double-precision floating point number whose value is equivalent to value.</returns> /// <returns>A double-precision floating point number whose value is equivalent to value.</returns>
@@ -171,55 +171,71 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns a Boolean value converted from one byte at a specified position in a byte array. /// Returns a Boolean value converted from one byte at a specified position in a byte array.
/// </summary> /// </summary>
/// <param name="value">An array of bytes.</param> /// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <returns>true if the byte at <see cref="startIndex"/> in value is nonzero; otherwise, false.</returns> /// <returns>true if the byte at <see cref="startIndex" /> in value is nonzero; otherwise, false.</returns>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException"><see cref="startIndex"/> is less than zero or greater than the length of value minus 1.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// <see cref="startIndex" /> is less than zero or greater than the
/// length of value minus 1.
/// </exception>
public static bool ToBoolean(byte[] value, int startIndex) public static bool ToBoolean(byte[] value, int startIndex)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Returns a Unicode character converted from two bytes at a specified position in a byte array. /// Returns a Unicode character converted from two bytes at a specified position in a byte array.
/// </summary> /// </summary>
/// <param name="value">An array.</param> /// <param name="value">An array.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <returns>A character formed by two bytes beginning at <see cref="startIndex"/>.</returns> /// <returns>A character formed by two bytes beginning at <see cref="startIndex" />.</returns>
/// <exception cref="System.ArgumentException"><see cref="startIndex"/> equals the length of value minus 1.</exception> /// <exception cref="System.ArgumentException"><see cref="startIndex" /> equals the length of value minus 1.</exception>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException"><see cref="startIndex"/> is less than zero or greater than the length of value minus 1.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// <see cref="startIndex" /> is less than zero or greater than the
/// length of value minus 1.
/// </exception>
public static char ToChar(byte[] value, int startIndex) public static char ToChar(byte[] value, int startIndex)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Returns a double-precision floating point number converted from eight bytes at a specified position in a byte array. /// Returns a double-precision floating point number converted from eight bytes at a specified position in a byte
/// array.
/// </summary> /// </summary>
/// <param name="value">An array of bytes.</param> /// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <returns>A double precision floating point number formed by eight bytes beginning at <see cref="startIndex"/>.</returns> /// <returns>A double precision floating point number formed by eight bytes beginning at <see cref="startIndex" />.</returns>
/// <exception cref="System.ArgumentException"><see cref="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.</exception> /// <exception cref="System.ArgumentException">
/// <see cref="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.
/// </exception>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException"><see cref="startIndex"/> is less than zero or greater than the length of value minus 1.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// <see cref="startIndex" /> is less than zero or greater than the
/// length of value minus 1.
/// </exception>
public static double ToDouble(byte[] value, int startIndex) public static double ToDouble(byte[] value, int startIndex)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array. /// Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array.
/// </summary> /// </summary>
/// <param name="value">An array of bytes.</param> /// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <returns>A 16-bit signed integer formed by two bytes beginning at <see cref="startIndex"/>.</returns> /// <returns>A 16-bit signed integer formed by two bytes beginning at <see cref="startIndex" />.</returns>
/// <exception cref="System.ArgumentException"><see cref="startIndex"/> equals the length of value minus 1.</exception> /// <exception cref="System.ArgumentException"><see cref="startIndex" /> equals the length of value minus 1.</exception>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException">startIndex is less than zero or greater than the length of value minus 1.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// startIndex is less than zero or greater than the length of value
/// minus 1.
/// </exception>
public static short ToInt16(byte[] value, int startIndex) public static short ToInt16(byte[] value, int startIndex)
{ {
return !IsLittleEndian return !IsLittleEndian
@@ -228,14 +244,20 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array. /// Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array.
/// </summary> /// </summary>
/// <param name="value">An array of bytes.</param> /// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <returns>A 32-bit signed integer formed by four bytes beginning at <see cref="startIndex"/>.</returns> /// <returns>A 32-bit signed integer formed by four bytes beginning at <see cref="startIndex" />.</returns>
/// <exception cref="System.ArgumentException"><see cref="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.</exception> /// <exception cref="System.ArgumentException">
/// <see cref="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.
/// </exception>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException">startIndex is less than zero or greater than the length of value minus 1.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// startIndex is less than zero or greater than the length of value
/// minus 1.
/// </exception>
public static int ToInt32(byte[] value, int startIndex) public static int ToInt32(byte[] value, int startIndex)
{ {
return !IsLittleEndian return !IsLittleEndian
@@ -244,14 +266,20 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array. /// Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array.
/// </summary> /// </summary>
/// <param name="value">An array of bytes.</param> /// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <returns>A 64-bit signed integer formed by eight bytes beginning at <see cref="startIndex"/>.</returns> /// <returns>A 64-bit signed integer formed by eight bytes beginning at <see cref="startIndex" />.</returns>
/// <exception cref="System.ArgumentException"><see cref="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.</exception> /// <exception cref="System.ArgumentException">
/// <see cref="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.
/// </exception>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException"><see cref="startIndex"/> is less than zero or greater than the length of value minus 1.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// <see cref="startIndex" /> is less than zero or greater than the
/// length of value minus 1.
/// </exception>
public static long ToInt64(byte[] value, int startIndex) public static long ToInt64(byte[] value, int startIndex)
{ {
return !IsLittleEndian return !IsLittleEndian
@@ -260,14 +288,21 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns a single-precision floating point number converted from four bytes at a specified position in a byte array. /// Returns a single-precision floating point number converted from four bytes at a specified position in a byte
/// array.
/// </summary> /// </summary>
/// <param name="value">An array of bytes.</param> /// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <returns>A single-precision floating point number formed by four bytes beginning at <see cref="startIndex"/>.</returns> /// <returns>A single-precision floating point number formed by four bytes beginning at <see cref="startIndex" />.</returns>
/// <exception cref="System.ArgumentException"><see cref="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.</exception> /// <exception cref="System.ArgumentException">
/// <see cref="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.
/// </exception>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException"><see cref="startIndex"/> is less than zero or greater than the length of value minus 1.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// <see cref="startIndex" /> is less than zero or greater than the
/// length of value minus 1.
/// </exception>
public static float ToSingle(byte[] value, int startIndex) public static float ToSingle(byte[] value, int startIndex)
{ {
return !IsLittleEndian return !IsLittleEndian
@@ -276,10 +311,14 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string representation. /// Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string
/// representation.
/// </summary> /// </summary>
/// <param name="value">An array of bytes.</param> /// <param name="value">An array of bytes.</param>
/// <returns>A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A".</returns> /// <returns>
/// A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding
/// element in value; for example, "7F-2C-4A".
/// </returns>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
public static string ToString(byte[] value) public static string ToString(byte[] value)
{ {
@@ -287,13 +326,20 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation. /// Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string
/// representation.
/// </summary> /// </summary>
/// <param name="value">An array of bytes.</param> /// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <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".</returns> /// <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".
/// </returns>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException">startIndex is less than zero or greater than the length of value minus 1.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// startIndex is less than zero or greater than the length of value
/// minus 1.
/// </exception>
public static string ToString(byte[] value, int startIndex) public static string ToString(byte[] value, int startIndex)
{ {
return !IsLittleEndian return !IsLittleEndian
@@ -302,15 +348,25 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation. /// Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string
/// representation.
/// </summary> /// </summary>
/// <param name="value">An array of bytes.</param> /// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <param name="length">The number of array elements in value to convert.</param> /// <param name="length">The number of array elements in value to convert.</param>
/// <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".</returns> /// <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".
/// </returns>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="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.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// <exception cref="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.</exception> /// startIndex or length is less than zero. -or- startIndex is greater
/// than zero and is greater than or equal to the length of value.
/// </exception>
/// <exception cref="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.
/// </exception>
public static string ToString(byte[] value, int startIndex, int length) public static string ToString(byte[] value, int startIndex, int length)
{ {
return !IsLittleEndian return !IsLittleEndian
@@ -319,14 +375,17 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array. /// Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.
/// </summary> /// </summary>
/// <param name="value">The array of bytes.</param> /// <param name="value">The array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <returns>A 16-bit unsigned integer formed by two bytes beginning at startIndex.</returns> /// <returns>A 16-bit unsigned integer formed by two bytes beginning at startIndex.</returns>
/// <exception cref="System.ArgumentException">startIndex equals the length of value minus 1.</exception> /// <exception cref="System.ArgumentException">startIndex equals the length of value minus 1.</exception>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException">startIndex is less than zero or greater than the length of value minus 1.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// startIndex is less than zero or greater than the length of value
/// minus 1.
/// </exception>
public static ushort ToUInt16(byte[] value, int startIndex) public static ushort ToUInt16(byte[] value, int startIndex)
{ {
return !IsLittleEndian return !IsLittleEndian
@@ -335,14 +394,20 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array. /// Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array.
/// </summary> /// </summary>
/// <param name="value">An array of bytes.</param> /// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <returns>A 32-bit unsigned integer formed by four bytes beginning at startIndex.</returns> /// <returns>A 32-bit unsigned integer formed by four bytes beginning at startIndex.</returns>
/// <exception cref="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.</exception> /// <exception cref="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.
/// </exception>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException">startIndex is less than zero or greater than the length of value minus 1.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// startIndex is less than zero or greater than the length of value
/// minus 1.
/// </exception>
public static uint ToUInt32(byte[] value, int startIndex) public static uint ToUInt32(byte[] value, int startIndex)
{ {
return !IsLittleEndian return !IsLittleEndian
@@ -351,14 +416,20 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array. /// Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array.
/// </summary> /// </summary>
/// <param name="value">An array of bytes.</param> /// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param> /// <param name="startIndex">The starting position within value.</param>
/// <returns>A 64-bit unsigned integer formed by the eight bytes beginning at startIndex.</returns> /// <returns>A 64-bit unsigned integer formed by the eight bytes beginning at startIndex.</returns>
/// <exception cref="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.</exception> /// <exception cref="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.
/// </exception>
/// <exception cref="System.ArgumentNullException">value is null.</exception> /// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException">startIndex is less than zero or greater than the length of value minus 1.</exception> /// <exception cref="System.ArgumentOutOfRangeException">
/// startIndex is less than zero or greater than the length of value
/// minus 1.
/// </exception>
public static ulong ToUInt64(byte[] value, int startIndex) public static ulong ToUInt64(byte[] value, int startIndex)
{ {
return !IsLittleEndian return !IsLittleEndian

View File

@@ -40,8 +40,8 @@ namespace DiscImageChef
public static class BigEndianMarshal public static class BigEndianMarshal
{ {
/// <summary> /// <summary>
/// Marshals a big endian structure from a byte array. /// Marshals a big endian structure from a byte array.
/// Nested structures are still marshalled as little endian. /// Nested structures are still marshalled as little endian.
/// </summary> /// </summary>
/// <returns>The structure.</returns> /// <returns>The structure.</returns>
/// <param name="bytes">Byte array.</param> /// <param name="bytes">Byte array.</param>
@@ -55,8 +55,8 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Swaps endian of structure members that correspond to numerical types. /// Swaps endian of structure members that correspond to numerical types.
/// Does not traverse nested structures. /// Does not traverse nested structures.
/// </summary> /// </summary>
/// <returns>The structure with its members endian swapped.</returns> /// <returns>The structure with its members endian swapped.</returns>
/// <param name="str">The structure.</param> /// <param name="str">The structure.</param>

View File

@@ -35,7 +35,7 @@ namespace DiscImageChef.Helpers
public static class CHS public static class CHS
{ {
/// <summary> /// <summary>
/// Converts a CHS position to a LBA one /// Converts a CHS position to a LBA one
/// </summary> /// </summary>
/// <param name="cyl">Cylinder</param> /// <param name="cyl">Cylinder</param>
/// <param name="head">Head</param> /// <param name="head">Head</param>

View File

@@ -35,7 +35,7 @@ namespace DiscImageChef
public static partial class ArrayHelpers public static partial class ArrayHelpers
{ {
/// <summary> /// <summary>
/// Compares two byte arrays /// Compares two byte arrays
/// </summary> /// </summary>
/// <param name="different"><c>true</c> if they are different in any way</param> /// <param name="different"><c>true</c> if they are different in any way</param>
/// <param name="sameSize"><c>true</c> if they have the same size</param> /// <param name="sameSize"><c>true</c> if they have the same size</param>

View File

@@ -35,7 +35,7 @@ namespace DiscImageChef.Helpers
public static class CountBits public static class CountBits
{ {
/// <summary> /// <summary>
/// Counts the number of bits set to <c>true</c> in a number /// Counts the number of bits set to <c>true</c> in a number
/// </summary> /// </summary>
/// <param name="number">Number</param> /// <param name="number">Number</param>
/// <returns>Bits set to <c>true</c></returns> /// <returns>Bits set to <c>true</c></returns>

View File

@@ -42,13 +42,13 @@ namespace DiscImageChef
static readonly DateTime MacEpoch = new DateTime(1904, 1, 1, 0, 0, 0); static readonly DateTime MacEpoch = new DateTime(1904, 1, 1, 0, 0, 0);
static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0);
/// <summary> /// <summary>
/// Day 0 of Julian Date system /// Day 0 of Julian Date system
/// </summary> /// </summary>
static readonly DateTime JulianEpoch = new DateTime(1858, 11, 17, 0, 0, 0); static readonly DateTime JulianEpoch = new DateTime(1858, 11, 17, 0, 0, 0);
static readonly DateTime AmigaEpoch = new DateTime(1978, 1, 1, 0, 0, 0); static readonly DateTime AmigaEpoch = new DateTime(1978, 1, 1, 0, 0, 0);
/// <summary> /// <summary>
/// Converts a Macintosh timestamp to a .NET DateTime /// Converts a Macintosh timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="macTimeStamp">Macintosh timestamp (seconds since 1st Jan. 1904)</param> /// <param name="macTimeStamp">Macintosh timestamp (seconds since 1st Jan. 1904)</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -58,7 +58,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a Lisa timestamp to a .NET DateTime /// Converts a Lisa timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="lisaTimeStamp">Lisa timestamp (seconds since 1st Jan. 1901)</param> /// <param name="lisaTimeStamp">Lisa timestamp (seconds since 1st Jan. 1901)</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -68,7 +68,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a UNIX timestamp to a .NET DateTime /// Converts a UNIX timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param> /// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -78,7 +78,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a UNIX timestamp to a .NET DateTime /// Converts a UNIX timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param> /// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -88,7 +88,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a UNIX timestamp to a .NET DateTime /// Converts a UNIX timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param> /// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -98,7 +98,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a UNIX timestamp to a .NET DateTime /// Converts a UNIX timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="seconds">Seconds since 1st Jan. 1970)</param> /// <param name="seconds">Seconds since 1st Jan. 1970)</param>
/// <param name="nanoseconds">Nanoseconds</param> /// <param name="nanoseconds">Nanoseconds</param>
@@ -109,7 +109,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a UNIX timestamp to a .NET DateTime /// Converts a UNIX timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param> /// <param name="unixTimeStamp">UNIX timestamp (seconds since 1st Jan. 1970)</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -119,7 +119,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a High Sierra Format timestamp to a .NET DateTime /// Converts a High Sierra Format timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="vdDateTime">High Sierra Format timestamp</param> /// <param name="vdDateTime">High Sierra Format timestamp</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -132,7 +132,7 @@ namespace DiscImageChef
// TODO: Timezone // TODO: Timezone
/// <summary> /// <summary>
/// Converts an ISO9660 timestamp to a .NET DateTime /// Converts an ISO9660 timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="vdDateTime">ISO9660 timestamp</param> /// <param name="vdDateTime">ISO9660 timestamp</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -183,7 +183,8 @@ namespace DiscImageChef
twocharvalue[1] = vdDateTime[15]; twocharvalue[1] = vdDateTime[15];
DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hundredths = \"{0}\"", DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hundredths = \"{0}\"",
StringHandlers.CToString(twocharvalue, Encoding.ASCII)); StringHandlers.CToString(twocharvalue, Encoding.ASCII));
if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out int hundredths)) hundredths = 0; if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out int hundredths))
hundredths = 0;
DicConsole.DebugWriteLine("ISO9600ToDateTime handler", DicConsole.DebugWriteLine("ISO9600ToDateTime handler",
"decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);", "decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);",
@@ -195,7 +196,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a VMS timestamp to a .NET DateTime /// Converts a VMS timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="vmsDate">VMS timestamp (tenths of microseconds since day 0 of the Julian Date)</param> /// <param name="vmsDate">VMS timestamp (tenths of microseconds since day 0 of the Julian Date)</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -207,7 +208,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts an Amiga timestamp to a .NET DateTime /// Converts an Amiga timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="days">Days since the 1st Jan. 1978</param> /// <param name="days">Days since the 1st Jan. 1978</param>
/// <param name="minutes">Minutes since o'clock</param> /// <param name="minutes">Minutes since o'clock</param>
@@ -221,7 +222,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts an UCSD Pascal timestamp to a .NET DateTime /// Converts an UCSD Pascal timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="dateRecord">UCSD Pascal timestamp</param> /// <param name="dateRecord">UCSD Pascal timestamp</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -238,7 +239,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a DOS timestamp to a .NET DateTime /// Converts a DOS timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="date">Date</param> /// <param name="date">Date</param>
/// <param name="time">Time</param> /// <param name="time">Time</param>
@@ -266,7 +267,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a CP/M timestamp to .NET DateTime /// Converts a CP/M timestamp to .NET DateTime
/// </summary> /// </summary>
/// <param name="timestamp">CP/M timestamp</param> /// <param name="timestamp">CP/M timestamp</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -284,7 +285,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts an ECMA timestamp to a .NET DateTime /// Converts an ECMA timestamp to a .NET DateTime
/// </summary> /// </summary>
/// <param name="typeAndTimeZone">Timezone</param> /// <param name="typeAndTimeZone">Timezone</param>
/// <param name="year">Year</param> /// <param name="year">Year</param>
@@ -322,7 +323,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Convers a Solaris high resolution timestamp to .NET DateTime /// Convers a Solaris high resolution timestamp to .NET DateTime
/// </summary> /// </summary>
/// <param name="hrTimeStamp">Solaris high resolution timestamp</param> /// <param name="hrTimeStamp">Solaris high resolution timestamp</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -332,7 +333,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts an OS-9 timestamp to .NET DateTime /// Converts an OS-9 timestamp to .NET DateTime
/// </summary> /// </summary>
/// <param name="date">OS-9 timestamp</param> /// <param name="date">OS-9 timestamp</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -354,7 +355,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a LIF timestamp to .NET DateTime /// Converts a LIF timestamp to .NET DateTime
/// </summary> /// </summary>
/// <param name="date">LIF timestamp</param> /// <param name="date">LIF timestamp</param>
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
@@ -366,7 +367,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a LIF timestamp to .NET DateTime /// Converts a LIF timestamp to .NET DateTime
/// </summary> /// </summary>
/// <param name="year">Yer</param> /// <param name="year">Yer</param>
/// <param name="month">Month</param> /// <param name="month">Month</param>

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents namespace Extents
{ {
/// <summary> /// <summary>
/// Implements extents for <see cref="byte"/> /// Implements extents for <see cref="byte" />
/// </summary> /// </summary>
public class ExtentsByte public class ExtentsByte
{ {
List<Tuple<byte, byte>> backend; List<Tuple<byte, byte>> backend;
/// <summary> /// <summary>
/// Initialize an empty list of extents /// Initialize an empty list of extents
/// </summary> /// </summary>
public ExtentsByte() public ExtentsByte()
{ {
@@ -52,7 +52,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Initializes extents with an specific list /// Initializes extents with an specific list
/// </summary> /// </summary>
/// <param name="list">List of extents as tuples "start, end"</param> /// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsByte(IEnumerable<Tuple<byte, byte>> list) public ExtentsByte(IEnumerable<Tuple<byte, byte>> list)
@@ -61,12 +61,12 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Gets a count of how many extents are stored /// Gets a count of how many extents are stored
/// </summary> /// </summary>
public int Count => backend.Count; public int Count => backend.Count;
/// <summary> /// <summary>
/// Adds the specified number to the corresponding extent, or creates a new one /// Adds the specified number to the corresponding extent, or creates a new one
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
public void Add(byte item) public void Add(byte item)
@@ -123,11 +123,14 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Adds a new extent /// Adds a new extent
/// </summary> /// </summary>
/// <param name="start">First element of the extent</param> /// <param name="start">First element of the extent</param>
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param> /// <param name="end">
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param> /// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
/// for
/// </param>
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
public void Add(byte start, byte end, bool run = false) public void Add(byte start, byte end, bool run = false)
{ {
byte realEnd; byte realEnd;
@@ -139,7 +142,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Checks if the specified item is contained by an extent on this instance /// Checks if the specified item is contained by an extent on this instance
/// </summary> /// </summary>
/// <param name="item">Item to seach for</param> /// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns> /// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes all extents from this instance /// Removes all extents from this instance
/// </summary> /// </summary>
public void Clear() public void Clear()
{ {
@@ -157,7 +160,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes an item from the extents in this instance /// Removes an item from the extents in this instance
/// </summary> /// </summary>
/// <param name="item">Item to remove</param> /// <param name="item">Item to remove</param>
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns> /// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
@@ -215,16 +218,17 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element /// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
/// last element
/// </summary> /// </summary>
/// <returns>Array of <see cref="Tuple"/></returns> /// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<byte, byte>[] ToArray() public Tuple<byte, byte>[] ToArray()
{ {
return backend.ToArray(); return backend.ToArray();
} }
/// <summary> /// <summary>
/// Gets the first element of the extent that contains the specified item /// Gets the first element of the extent that contains the specified item
/// </summary> /// </summary>
/// <param name="item">Item</param> /// <param name="item">Item</param>
/// <param name="start">First element of extent</param> /// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(byte item, out byte start) public bool GetStart(byte item, out byte start)
{ {
start = 0; start = 0;
foreach(Tuple<byte, byte> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) { foreach(Tuple<byte, byte> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
{
start = extent.Item1; start = extent.Item1;
return true; return true;
} }

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents namespace Extents
{ {
/// <summary> /// <summary>
/// Implements extents for <see cref="int"/> /// Implements extents for <see cref="int" />
/// </summary> /// </summary>
public class ExtentsInt public class ExtentsInt
{ {
List<Tuple<int, int>> backend; List<Tuple<int, int>> backend;
/// <summary> /// <summary>
/// Initialize an empty list of extents /// Initialize an empty list of extents
/// </summary> /// </summary>
public ExtentsInt() public ExtentsInt()
{ {
@@ -52,7 +52,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Initializes extents with an specific list /// Initializes extents with an specific list
/// </summary> /// </summary>
/// <param name="list">List of extents as tuples "start, end"</param> /// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsInt(IEnumerable<Tuple<int, int>> list) public ExtentsInt(IEnumerable<Tuple<int, int>> list)
@@ -61,12 +61,12 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Gets a count of how many extents are stored /// Gets a count of how many extents are stored
/// </summary> /// </summary>
public int Count => backend.Count; public int Count => backend.Count;
/// <summary> /// <summary>
/// Adds the specified number to the corresponding extent, or creates a new one /// Adds the specified number to the corresponding extent, or creates a new one
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
public void Add(int item) public void Add(int item)
@@ -123,11 +123,14 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Adds a new extent /// Adds a new extent
/// </summary> /// </summary>
/// <param name="start">First element of the extent</param> /// <param name="start">First element of the extent</param>
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param> /// <param name="end">
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param> /// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
/// for
/// </param>
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
public void Add(int start, int end, bool run = false) public void Add(int start, int end, bool run = false)
{ {
int realEnd; int realEnd;
@@ -139,7 +142,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Checks if the specified item is contained by an extent on this instance /// Checks if the specified item is contained by an extent on this instance
/// </summary> /// </summary>
/// <param name="item">Item to seach for</param> /// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns> /// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes all extents from this instance /// Removes all extents from this instance
/// </summary> /// </summary>
public void Clear() public void Clear()
{ {
@@ -157,7 +160,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes an item from the extents in this instance /// Removes an item from the extents in this instance
/// </summary> /// </summary>
/// <param name="item">Item to remove</param> /// <param name="item">Item to remove</param>
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns> /// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
@@ -215,16 +218,17 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element /// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
/// last element
/// </summary> /// </summary>
/// <returns>Array of <see cref="Tuple"/></returns> /// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<int, int>[] ToArray() public Tuple<int, int>[] ToArray()
{ {
return backend.ToArray(); return backend.ToArray();
} }
/// <summary> /// <summary>
/// Gets the first element of the extent that contains the specified item /// Gets the first element of the extent that contains the specified item
/// </summary> /// </summary>
/// <param name="item">Item</param> /// <param name="item">Item</param>
/// <param name="start">First element of extent</param> /// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(int item, out int start) public bool GetStart(int item, out int start)
{ {
start = 0; start = 0;
foreach(Tuple<int, int> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) { foreach(Tuple<int, int> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
{
start = extent.Item1; start = extent.Item1;
return true; return true;
} }

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents namespace Extents
{ {
/// <summary> /// <summary>
/// Implements extents for <see cref="long"/> /// Implements extents for <see cref="long" />
/// </summary> /// </summary>
public class ExtentsLong public class ExtentsLong
{ {
List<Tuple<long, long>> backend; List<Tuple<long, long>> backend;
/// <summary> /// <summary>
/// Initialize an empty list of extents /// Initialize an empty list of extents
/// </summary> /// </summary>
public ExtentsLong() public ExtentsLong()
{ {
@@ -52,7 +52,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Initializes extents with an specific list /// Initializes extents with an specific list
/// </summary> /// </summary>
/// <param name="list">List of extents as tuples "start, end"</param> /// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsLong(IEnumerable<Tuple<long, long>> list) public ExtentsLong(IEnumerable<Tuple<long, long>> list)
@@ -61,12 +61,12 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Gets a count of how many extents are stored /// Gets a count of how many extents are stored
/// </summary> /// </summary>
public int Count => backend.Count; public int Count => backend.Count;
/// <summary> /// <summary>
/// Adds the specified number to the corresponding extent, or creates a new one /// Adds the specified number to the corresponding extent, or creates a new one
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
public void Add(long item) public void Add(long item)
@@ -123,11 +123,14 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Adds a new extent /// Adds a new extent
/// </summary> /// </summary>
/// <param name="start">First element of the extent</param> /// <param name="start">First element of the extent</param>
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param> /// <param name="end">
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param> /// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
/// for
/// </param>
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
public void Add(long start, long end, bool run = false) public void Add(long start, long end, bool run = false)
{ {
long realEnd; long realEnd;
@@ -139,7 +142,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Checks if the specified item is contained by an extent on this instance /// Checks if the specified item is contained by an extent on this instance
/// </summary> /// </summary>
/// <param name="item">Item to seach for</param> /// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns> /// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes all extents from this instance /// Removes all extents from this instance
/// </summary> /// </summary>
public void Clear() public void Clear()
{ {
@@ -157,7 +160,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes an item from the extents in this instance /// Removes an item from the extents in this instance
/// </summary> /// </summary>
/// <param name="item">Item to remove</param> /// <param name="item">Item to remove</param>
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns> /// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
@@ -215,16 +218,17 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element /// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
/// last element
/// </summary> /// </summary>
/// <returns>Array of <see cref="Tuple"/></returns> /// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<long, long>[] ToArray() public Tuple<long, long>[] ToArray()
{ {
return backend.ToArray(); return backend.ToArray();
} }
/// <summary> /// <summary>
/// Gets the first element of the extent that contains the specified item /// Gets the first element of the extent that contains the specified item
/// </summary> /// </summary>
/// <param name="item">Item</param> /// <param name="item">Item</param>
/// <param name="start">First element of extent</param> /// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(long item, out long start) public bool GetStart(long item, out long start)
{ {
start = 0; start = 0;
foreach(Tuple<long, long> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) { foreach(Tuple<long, long> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
{
start = extent.Item1; start = extent.Item1;
return true; return true;
} }

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents namespace Extents
{ {
/// <summary> /// <summary>
/// Implements extents for <see cref="sbyte"/> /// Implements extents for <see cref="sbyte" />
/// </summary> /// </summary>
public class ExtentsSByte public class ExtentsSByte
{ {
List<Tuple<sbyte, sbyte>> backend; List<Tuple<sbyte, sbyte>> backend;
/// <summary> /// <summary>
/// Initialize an empty list of extents /// Initialize an empty list of extents
/// </summary> /// </summary>
public ExtentsSByte() public ExtentsSByte()
{ {
@@ -52,7 +52,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Initializes extents with an specific list /// Initializes extents with an specific list
/// </summary> /// </summary>
/// <param name="list">List of extents as tuples "start, end"</param> /// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsSByte(IEnumerable<Tuple<sbyte, sbyte>> list) public ExtentsSByte(IEnumerable<Tuple<sbyte, sbyte>> list)
@@ -61,12 +61,12 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Gets a count of how many extents are stored /// Gets a count of how many extents are stored
/// </summary> /// </summary>
public int Count => backend.Count; public int Count => backend.Count;
/// <summary> /// <summary>
/// Adds the specified number to the corresponding extent, or creates a new one /// Adds the specified number to the corresponding extent, or creates a new one
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
public void Add(sbyte item) public void Add(sbyte item)
@@ -123,11 +123,14 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Adds a new extent /// Adds a new extent
/// </summary> /// </summary>
/// <param name="start">First element of the extent</param> /// <param name="start">First element of the extent</param>
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param> /// <param name="end">
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param> /// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
/// for
/// </param>
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
public void Add(sbyte start, sbyte end, bool run = false) public void Add(sbyte start, sbyte end, bool run = false)
{ {
sbyte realEnd; sbyte realEnd;
@@ -139,7 +142,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Checks if the specified item is contained by an extent on this instance /// Checks if the specified item is contained by an extent on this instance
/// </summary> /// </summary>
/// <param name="item">Item to seach for</param> /// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns> /// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes all extents from this instance /// Removes all extents from this instance
/// </summary> /// </summary>
public void Clear() public void Clear()
{ {
@@ -157,7 +160,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes an item from the extents in this instance /// Removes an item from the extents in this instance
/// </summary> /// </summary>
/// <param name="item">Item to remove</param> /// <param name="item">Item to remove</param>
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns> /// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
@@ -215,16 +218,17 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element /// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
/// last element
/// </summary> /// </summary>
/// <returns>Array of <see cref="Tuple"/></returns> /// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<sbyte, sbyte>[] ToArray() public Tuple<sbyte, sbyte>[] ToArray()
{ {
return backend.ToArray(); return backend.ToArray();
} }
/// <summary> /// <summary>
/// Gets the first element of the extent that contains the specified item /// Gets the first element of the extent that contains the specified item
/// </summary> /// </summary>
/// <param name="item">Item</param> /// <param name="item">Item</param>
/// <param name="start">First element of extent</param> /// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(sbyte item, out sbyte start) public bool GetStart(sbyte item, out sbyte start)
{ {
start = 0; start = 0;
foreach(Tuple<sbyte, sbyte> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) { foreach(Tuple<sbyte, sbyte> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
{
start = extent.Item1; start = extent.Item1;
return true; return true;
} }

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents namespace Extents
{ {
/// <summary> /// <summary>
/// Implements extents for <see cref="short"/> /// Implements extents for <see cref="short" />
/// </summary> /// </summary>
public class ExtentsShort public class ExtentsShort
{ {
List<Tuple<short, short>> backend; List<Tuple<short, short>> backend;
/// <summary> /// <summary>
/// Initialize an empty list of extents /// Initialize an empty list of extents
/// </summary> /// </summary>
public ExtentsShort() public ExtentsShort()
{ {
@@ -52,7 +52,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Initializes extents with an specific list /// Initializes extents with an specific list
/// </summary> /// </summary>
/// <param name="list">List of extents as tuples "start, end"</param> /// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsShort(IEnumerable<Tuple<short, short>> list) public ExtentsShort(IEnumerable<Tuple<short, short>> list)
@@ -61,12 +61,12 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Gets a count of how many extents are stored /// Gets a count of how many extents are stored
/// </summary> /// </summary>
public int Count => backend.Count; public int Count => backend.Count;
/// <summary> /// <summary>
/// Adds the specified number to the corresponding extent, or creates a new one /// Adds the specified number to the corresponding extent, or creates a new one
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
public void Add(short item) public void Add(short item)
@@ -123,11 +123,14 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Adds a new extent /// Adds a new extent
/// </summary> /// </summary>
/// <param name="start">First element of the extent</param> /// <param name="start">First element of the extent</param>
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param> /// <param name="end">
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param> /// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
/// for
/// </param>
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
public void Add(short start, short end, bool run = false) public void Add(short start, short end, bool run = false)
{ {
short realEnd; short realEnd;
@@ -139,7 +142,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Checks if the specified item is contained by an extent on this instance /// Checks if the specified item is contained by an extent on this instance
/// </summary> /// </summary>
/// <param name="item">Item to seach for</param> /// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns> /// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes all extents from this instance /// Removes all extents from this instance
/// </summary> /// </summary>
public void Clear() public void Clear()
{ {
@@ -157,7 +160,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes an item from the extents in this instance /// Removes an item from the extents in this instance
/// </summary> /// </summary>
/// <param name="item">Item to remove</param> /// <param name="item">Item to remove</param>
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns> /// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
@@ -215,16 +218,17 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element /// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
/// last element
/// </summary> /// </summary>
/// <returns>Array of <see cref="Tuple"/></returns> /// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<short, short>[] ToArray() public Tuple<short, short>[] ToArray()
{ {
return backend.ToArray(); return backend.ToArray();
} }
/// <summary> /// <summary>
/// Gets the first element of the extent that contains the specified item /// Gets the first element of the extent that contains the specified item
/// </summary> /// </summary>
/// <param name="item">Item</param> /// <param name="item">Item</param>
/// <param name="start">First element of extent</param> /// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(short item, out short start) public bool GetStart(short item, out short start)
{ {
start = 0; start = 0;
foreach(Tuple<short, short> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) { foreach(Tuple<short, short> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
{
start = extent.Item1; start = extent.Item1;
return true; return true;
} }

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents namespace Extents
{ {
/// <summary> /// <summary>
/// Implements extents for <see cref="uint"/> /// Implements extents for <see cref="uint" />
/// </summary> /// </summary>
public class ExtentsUInt public class ExtentsUInt
{ {
List<Tuple<uint, uint>> backend; List<Tuple<uint, uint>> backend;
/// <summary> /// <summary>
/// Initialize an empty list of extents /// Initialize an empty list of extents
/// </summary> /// </summary>
public ExtentsUInt() public ExtentsUInt()
{ {
@@ -52,7 +52,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Initializes extents with an specific list /// Initializes extents with an specific list
/// </summary> /// </summary>
/// <param name="list">List of extents as tuples "start, end"</param> /// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsUInt(IEnumerable<Tuple<uint, uint>> list) public ExtentsUInt(IEnumerable<Tuple<uint, uint>> list)
@@ -61,12 +61,12 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Gets a count of how many extents are stored /// Gets a count of how many extents are stored
/// </summary> /// </summary>
public int Count => backend.Count; public int Count => backend.Count;
/// <summary> /// <summary>
/// Adds the specified number to the corresponding extent, or creates a new one /// Adds the specified number to the corresponding extent, or creates a new one
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
public void Add(uint item) public void Add(uint item)
@@ -123,11 +123,14 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Adds a new extent /// Adds a new extent
/// </summary> /// </summary>
/// <param name="start">First element of the extent</param> /// <param name="start">First element of the extent</param>
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param> /// <param name="end">
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param> /// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
/// for
/// </param>
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
public void Add(uint start, uint end, bool run = false) public void Add(uint start, uint end, bool run = false)
{ {
uint realEnd; uint realEnd;
@@ -139,7 +142,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Checks if the specified item is contained by an extent on this instance /// Checks if the specified item is contained by an extent on this instance
/// </summary> /// </summary>
/// <param name="item">Item to seach for</param> /// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns> /// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes all extents from this instance /// Removes all extents from this instance
/// </summary> /// </summary>
public void Clear() public void Clear()
{ {
@@ -157,7 +160,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes an item from the extents in this instance /// Removes an item from the extents in this instance
/// </summary> /// </summary>
/// <param name="item">Item to remove</param> /// <param name="item">Item to remove</param>
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns> /// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
@@ -215,16 +218,17 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element /// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
/// last element
/// </summary> /// </summary>
/// <returns>Array of <see cref="Tuple"/></returns> /// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<uint, uint>[] ToArray() public Tuple<uint, uint>[] ToArray()
{ {
return backend.ToArray(); return backend.ToArray();
} }
/// <summary> /// <summary>
/// Gets the first element of the extent that contains the specified item /// Gets the first element of the extent that contains the specified item
/// </summary> /// </summary>
/// <param name="item">Item</param> /// <param name="item">Item</param>
/// <param name="start">First element of extent</param> /// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(uint item, out uint start) public bool GetStart(uint item, out uint start)
{ {
start = 0; start = 0;
foreach(Tuple<uint, uint> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) { foreach(Tuple<uint, uint> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
{
start = extent.Item1; start = extent.Item1;
return true; return true;
} }

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents namespace Extents
{ {
/// <summary> /// <summary>
/// Implements extents for <see cref="ulong"/> /// Implements extents for <see cref="ulong" />
/// </summary> /// </summary>
public class ExtentsULong public class ExtentsULong
{ {
List<Tuple<ulong, ulong>> backend; List<Tuple<ulong, ulong>> backend;
/// <summary> /// <summary>
/// Initialize an empty list of extents /// Initialize an empty list of extents
/// </summary> /// </summary>
public ExtentsULong() public ExtentsULong()
{ {
@@ -52,7 +52,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Initializes extents with an specific list /// Initializes extents with an specific list
/// </summary> /// </summary>
/// <param name="list">List of extents as tuples "start, end"</param> /// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsULong(IEnumerable<Tuple<ulong, ulong>> list) public ExtentsULong(IEnumerable<Tuple<ulong, ulong>> list)
@@ -61,12 +61,12 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Gets a count of how many extents are stored /// Gets a count of how many extents are stored
/// </summary> /// </summary>
public int Count => backend.Count; public int Count => backend.Count;
/// <summary> /// <summary>
/// Adds the specified number to the corresponding extent, or creates a new one /// Adds the specified number to the corresponding extent, or creates a new one
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
public void Add(ulong item) public void Add(ulong item)
@@ -123,11 +123,14 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Adds a new extent /// Adds a new extent
/// </summary> /// </summary>
/// <param name="start">First element of the extent</param> /// <param name="start">First element of the extent</param>
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param> /// <param name="end">
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param> /// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
/// for
/// </param>
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
public void Add(ulong start, ulong end, bool run = false) public void Add(ulong start, ulong end, bool run = false)
{ {
ulong realEnd; ulong realEnd;
@@ -139,7 +142,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Checks if the specified item is contained by an extent on this instance /// Checks if the specified item is contained by an extent on this instance
/// </summary> /// </summary>
/// <param name="item">Item to seach for</param> /// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns> /// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes all extents from this instance /// Removes all extents from this instance
/// </summary> /// </summary>
public void Clear() public void Clear()
{ {
@@ -157,7 +160,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes an item from the extents in this instance /// Removes an item from the extents in this instance
/// </summary> /// </summary>
/// <param name="item">Item to remove</param> /// <param name="item">Item to remove</param>
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns> /// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
@@ -215,16 +218,17 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element /// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
/// last element
/// </summary> /// </summary>
/// <returns>Array of <see cref="Tuple"/></returns> /// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<ulong, ulong>[] ToArray() public Tuple<ulong, ulong>[] ToArray()
{ {
return backend.ToArray(); return backend.ToArray();
} }
/// <summary> /// <summary>
/// Gets the first element of the extent that contains the specified item /// Gets the first element of the extent that contains the specified item
/// </summary> /// </summary>
/// <param name="item">Item</param> /// <param name="item">Item</param>
/// <param name="start">First element of extent</param> /// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(ulong item, out ulong start) public bool GetStart(ulong item, out ulong start)
{ {
start = 0; start = 0;
foreach(Tuple<ulong, ulong> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) { foreach(Tuple<ulong, ulong> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
{
start = extent.Item1; start = extent.Item1;
return true; return true;
} }

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents namespace Extents
{ {
/// <summary> /// <summary>
/// Implements extents for <see cref="ushort"/> /// Implements extents for <see cref="ushort" />
/// </summary> /// </summary>
public class ExtentsUShort public class ExtentsUShort
{ {
List<Tuple<ushort, ushort>> backend; List<Tuple<ushort, ushort>> backend;
/// <summary> /// <summary>
/// Initialize an empty list of extents /// Initialize an empty list of extents
/// </summary> /// </summary>
public ExtentsUShort() public ExtentsUShort()
{ {
@@ -52,7 +52,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Initializes extents with an specific list /// Initializes extents with an specific list
/// </summary> /// </summary>
/// <param name="list">List of extents as tuples "start, end"</param> /// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsUShort(IEnumerable<Tuple<ushort, ushort>> list) public ExtentsUShort(IEnumerable<Tuple<ushort, ushort>> list)
@@ -61,12 +61,12 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Gets a count of how many extents are stored /// Gets a count of how many extents are stored
/// </summary> /// </summary>
public int Count => backend.Count; public int Count => backend.Count;
/// <summary> /// <summary>
/// Adds the specified number to the corresponding extent, or creates a new one /// Adds the specified number to the corresponding extent, or creates a new one
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
public void Add(ushort item) public void Add(ushort item)
@@ -123,11 +123,14 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Adds a new extent /// Adds a new extent
/// </summary> /// </summary>
/// <param name="start">First element of the extent</param> /// <param name="start">First element of the extent</param>
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param> /// <param name="end">
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param> /// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
/// for
/// </param>
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
public void Add(ushort start, ushort end, bool run = false) public void Add(ushort start, ushort end, bool run = false)
{ {
ushort realEnd; ushort realEnd;
@@ -139,7 +142,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Checks if the specified item is contained by an extent on this instance /// Checks if the specified item is contained by an extent on this instance
/// </summary> /// </summary>
/// <param name="item">Item to seach for</param> /// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns> /// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes all extents from this instance /// Removes all extents from this instance
/// </summary> /// </summary>
public void Clear() public void Clear()
{ {
@@ -157,7 +160,7 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Removes an item from the extents in this instance /// Removes an item from the extents in this instance
/// </summary> /// </summary>
/// <param name="item">Item to remove</param> /// <param name="item">Item to remove</param>
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns> /// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
@@ -215,16 +218,17 @@ namespace Extents
} }
/// <summary> /// <summary>
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element /// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
/// last element
/// </summary> /// </summary>
/// <returns>Array of <see cref="Tuple"/></returns> /// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<ushort, ushort>[] ToArray() public Tuple<ushort, ushort>[] ToArray()
{ {
return backend.ToArray(); return backend.ToArray();
} }
/// <summary> /// <summary>
/// Gets the first element of the extent that contains the specified item /// Gets the first element of the extent that contains the specified item
/// </summary> /// </summary>
/// <param name="item">Item</param> /// <param name="item">Item</param>
/// <param name="start">First element of extent</param> /// <param name="start">First element of extent</param>
@@ -232,7 +236,9 @@ namespace Extents
public bool GetStart(ushort item, out ushort start) public bool GetStart(ushort item, out ushort start)
{ {
start = 0; start = 0;
foreach(Tuple<ushort, ushort> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) { foreach(Tuple<ushort, ushort> extent in
backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
{
start = extent.Item1; start = extent.Item1;
return true; return true;
} }

View File

@@ -38,7 +38,7 @@ namespace DiscImageChef
public static class PrintHex public static class PrintHex
{ {
/// <summary> /// <summary>
/// Prints a byte array as hexadecimal values to the console /// Prints a byte array as hexadecimal values to the console
/// </summary> /// </summary>
/// <param name="array">Array</param> /// <param name="array">Array</param>
/// <param name="width">Width of line</param> /// <param name="width">Width of line</param>
@@ -48,7 +48,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Prints a byte array as hexadecimal values to a string /// Prints a byte array as hexadecimal values to a string
/// </summary> /// </summary>
/// <param name="array">Array</param> /// <param name="array">Array</param>
/// <param name="width">Width of line</param> /// <param name="width">Width of line</param>

View File

@@ -38,7 +38,7 @@ namespace DiscImageChef
public static class StringHandlers public static class StringHandlers
{ {
/// <summary> /// <summary>
/// Converts a null-terminated (aka C string) ASCII byte array to a C# string /// Converts a null-terminated (aka C string) ASCII byte array to a C# string
/// </summary> /// </summary>
/// <returns>The corresponding C# string</returns> /// <returns>The corresponding C# string</returns>
/// <param name="CString">A null-terminated (aka C string) ASCII byte array</param> /// <param name="CString">A null-terminated (aka C string) ASCII byte array</param>
@@ -48,7 +48,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a null-terminated (aka C string) byte array with the specified encoding to a C# string /// Converts a null-terminated (aka C string) byte array with the specified encoding to a C# string
/// </summary> /// </summary>
/// <returns>The corresponding C# string</returns> /// <returns>The corresponding C# string</returns>
/// <param name="CString">A null-terminated (aka C string) byte array in the specified encoding</param> /// <param name="CString">A null-terminated (aka C string) byte array in the specified encoding</param>
@@ -86,7 +86,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a length-prefixed (aka Pascal string) ASCII byte array to a C# string /// Converts a length-prefixed (aka Pascal string) ASCII byte array to a C# string
/// </summary> /// </summary>
/// <returns>The corresponding C# string</returns> /// <returns>The corresponding C# string</returns>
/// <param name="PascalString">A length-prefixed (aka Pascal string) ASCII byte array</param> /// <param name="PascalString">A length-prefixed (aka Pascal string) ASCII byte array</param>
@@ -96,7 +96,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a length-prefixed (aka Pascal string) ASCII byte array to a C# string /// Converts a length-prefixed (aka Pascal string) ASCII byte array to a C# string
/// </summary> /// </summary>
/// <returns>The corresponding C# string</returns> /// <returns>The corresponding C# string</returns>
/// <param name="PascalString">A length-prefixed (aka Pascal string) ASCII byte array</param> /// <param name="PascalString">A length-prefixed (aka Pascal string) ASCII byte array</param>
@@ -123,7 +123,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a space (' ', 0x20, ASCII SPACE) padded ASCII byte array to a C# string /// Converts a space (' ', 0x20, ASCII SPACE) padded ASCII byte array to a C# string
/// </summary> /// </summary>
/// <returns>The corresponding C# string</returns> /// <returns>The corresponding C# string</returns>
/// <param name="SpacePaddedString">A space (' ', 0x20, ASCII SPACE) padded ASCII byte array</param> /// <param name="SpacePaddedString">A space (' ', 0x20, ASCII SPACE) padded ASCII byte array</param>
@@ -133,7 +133,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts a space (' ', 0x20, ASCII SPACE) padded ASCII byte array to a C# string /// Converts a space (' ', 0x20, ASCII SPACE) padded ASCII byte array to a C# string
/// </summary> /// </summary>
/// <returns>The corresponding C# string</returns> /// <returns>The corresponding C# string</returns>
/// <param name="SpacePaddedString">A space (' ', 0x20, ASCII SPACE) padded ASCII byte array</param> /// <param name="SpacePaddedString">A space (' ', 0x20, ASCII SPACE) padded ASCII byte array</param>
@@ -159,7 +159,7 @@ namespace DiscImageChef
} }
/// <summary> /// <summary>
/// Converts an OSTA compressed unicode byte array to a C# string /// Converts an OSTA compressed unicode byte array to a C# string
/// </summary> /// </summary>
/// <returns>The C# string.</returns> /// <returns>The C# string.</returns>
/// <param name="dstring">OSTA compressed unicode byte array.</param> /// <param name="dstring">OSTA compressed unicode byte array.</param>

View File

@@ -118,12 +118,12 @@ namespace DiscImageChef
public static ushort Swap(ushort x) public static ushort Swap(ushort x)
{ {
return (ushort) ((x << 8) | (x >> 8)); return (ushort)((x << 8) | (x >> 8));
} }
public static short Swap(short x) public static short Swap(short x)
{ {
return (short) ((x << 8) | ((x >> 8) & 0xFF)); return (short)((x << 8) | ((x >> 8) & 0xFF));
} }
public static uint Swap(uint x) public static uint Swap(uint x)
@@ -134,8 +134,8 @@ namespace DiscImageChef
public static int Swap(int x) public static int Swap(int x)
{ {
x = (int) (((x << 8) & 0xFF00FF00) | (((uint) x >> 8) & 0xFF00FF)); x = (int)(((x << 8) & 0xFF00FF00) | (((uint)x >> 8) & 0xFF00FF));
return (int) (((uint) x << 16) | (((uint) x >> 16) & 0xFFFF)); return (int)(((uint)x << 16) | (((uint)x >> 16) & 0xFFFF));
} }
} }
} }