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
{
/// <summary>
/// Fills an array with the specified value
/// Fills an array with the specified value
/// </summary>
/// <param name="destinationArray">Array</param>
/// <param name="value">Value</param>
@@ -44,7 +44,7 @@ namespace DiscImageChef
}
/// <summary>
/// Fills an array with the contents of the specified array
/// Fills an array with the contents of the specified array
/// </summary>
/// <param name="destinationArray">Array</param>
/// <param name="value">Value</param>
@@ -53,7 +53,8 @@ namespace DiscImageChef
{
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
Array.Copy(value, destinationArray, value.Length);
@@ -61,13 +62,14 @@ namespace DiscImageChef
int arrayToFillHalfLength = destinationArray.Length / 2;
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);
}
/// <summary>
/// Converts a byte array to its hexadecimal representation
/// Converts a byte array to its hexadecimal representation
/// </summary>
/// <param name="array">Byte array</param>
/// <param name="upper"><c>true</c> to use uppercase</param>

View File

@@ -37,7 +37,7 @@ namespace DiscImageChef
public static partial class ArrayHelpers
{
/// <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>
/// <param name="array">Array</param>
/// <returns>True if null or whitespace</returns>
@@ -47,7 +47,7 @@ namespace DiscImageChef
}
/// <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>
/// <param name="array">Array</param>
/// <returns>True if null</returns>

View File

@@ -36,21 +36,21 @@ using System.Linq;
namespace DiscImageChef
{
/// <summary>
/// Converts base data types to an array of bytes, and an array of bytes to base
/// data types.
/// All info taken from the meta data of System.BitConverter. This implementation
/// allows for Endianness consideration.
/// Converts base data types to an array of bytes, and an array of bytes to base
/// data types.
/// All info taken from the meta data of System.BitConverter. This implementation
/// allows for Endianness consideration.
/// </summary>
public static class BigEndianBitConverter
{
/// <summary>
/// Indicates the byte order ("endianess") in which data is stored in this computer
/// architecture.
/// Indicates the byte order ("endianess") in which data is stored in this computer
/// architecture.
/// </summary>
public static bool IsLittleEndian { get; set; }
/// <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>
/// <param name="value">The number to convert.</param>
/// <returns>A 64-bit signed integer whose value is equivalent to value.</returns>
@@ -61,7 +61,7 @@ namespace DiscImageChef
}
/// <summary>
/// Returns the specified Boolean value as an array of bytes.
/// Returns the specified Boolean value as an array of bytes.
/// </summary>
/// <param name="value">A Boolean value.</param>
/// <returns>An array of bytes with length 1.</returns>
@@ -71,7 +71,7 @@ namespace DiscImageChef
}
/// <summary>
/// Returns the specified Unicode character value as an array of bytes.
/// Returns the specified Unicode character value as an array of bytes.
/// </summary>
/// <param name="value">A character to convert.</param>
/// <returns>An array of bytes with length 2.</returns>
@@ -81,7 +81,7 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 8.</returns>
@@ -91,7 +91,7 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 4.</returns>
@@ -101,7 +101,7 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 4.</returns>
@@ -111,7 +111,7 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 8.</returns>
@@ -121,7 +121,7 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 2.</returns>
@@ -131,7 +131,7 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 4.</returns>
@@ -141,7 +141,7 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 8.</returns>
@@ -151,7 +151,7 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 2.</returns>
@@ -161,7 +161,7 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">The number to convert.</param>
/// <returns>A double-precision floating point number whose value is equivalent to value.</returns>
@@ -171,55 +171,71 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">An array of bytes.</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.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)
{
throw new NotImplementedException();
}
/// <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>
/// <param name="value">An array.</param>
/// <param name="startIndex">The starting position within value.</param>
/// <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>
/// <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.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)
{
throw new NotImplementedException();
}
/// <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>
/// <param name="value">An array of bytes.</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>
/// <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>
/// <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.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)
{
throw new NotImplementedException();
}
/// <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>
/// <param name="value">An array of bytes.</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>
/// <exception cref="System.ArgumentException"><see cref="startIndex"/> equals the length of value minus 1.</exception>
/// <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.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)
{
return !IsLittleEndian
@@ -228,14 +244,20 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">An array of bytes.</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>
/// <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>
/// <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.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)
{
return !IsLittleEndian
@@ -244,14 +266,20 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">An array of bytes.</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>
/// <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>
/// <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.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)
{
return !IsLittleEndian
@@ -260,14 +288,21 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">An array of bytes.</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>
/// <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>
/// <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.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)
{
return !IsLittleEndian
@@ -276,10 +311,14 @@ namespace DiscImageChef
}
/// <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>
/// <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>
public static string ToString(byte[] value)
{
@@ -287,13 +326,20 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">An array of bytes.</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.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)
{
return !IsLittleEndian
@@ -302,15 +348,25 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</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.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.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>
/// <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.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)
{
return !IsLittleEndian
@@ -319,14 +375,17 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">The array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param>
/// <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.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)
{
return !IsLittleEndian
@@ -335,14 +394,20 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param>
/// <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.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)
{
return !IsLittleEndian
@@ -351,14 +416,20 @@ namespace DiscImageChef
}
/// <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>
/// <param name="value">An array of bytes.</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>
/// <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.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)
{
return !IsLittleEndian

View File

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

View File

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

View File

@@ -35,7 +35,7 @@ namespace DiscImageChef
public static partial class ArrayHelpers
{
/// <summary>
/// Compares two byte arrays
/// Compares two byte arrays
/// </summary>
/// <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>

View File

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

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="byte"/>
/// Implements extents for <see cref="byte" />
/// </summary>
public class ExtentsByte
{
List<Tuple<byte, byte>> backend;
/// <summary>
/// Initialize an empty list of extents
/// Initialize an empty list of extents
/// </summary>
public ExtentsByte()
{
@@ -52,7 +52,7 @@ namespace Extents
}
/// <summary>
/// Initializes extents with an specific list
/// Initializes extents with an specific list
/// </summary>
/// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsByte(IEnumerable<Tuple<byte, byte>> list)
@@ -61,12 +61,12 @@ namespace Extents
}
/// <summary>
/// Gets a count of how many extents are stored
/// Gets a count of how many extents are stored
/// </summary>
public int Count => backend.Count;
/// <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>
/// <param name="item"></param>
public void Add(byte item)
@@ -123,11 +123,14 @@ namespace Extents
}
/// <summary>
/// Adds a new extent
/// Adds a new extent
/// </summary>
/// <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="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</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="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)
{
byte realEnd;
@@ -139,7 +142,7 @@ namespace Extents
}
/// <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>
/// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
}
/// <summary>
/// Removes all extents from this instance
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
@@ -157,7 +160,7 @@ namespace Extents
}
/// <summary>
/// Removes an item from the extents in this instance
/// Removes an item from the extents in this instance
/// </summary>
/// <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>
@@ -215,16 +218,17 @@ namespace Extents
}
/// <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>
/// <returns>Array of <see cref="Tuple"/></returns>
/// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<byte, byte>[] ToArray()
{
return backend.ToArray();
}
/// <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>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(byte item, out byte start)
{
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;
return true;
}

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="int"/>
/// Implements extents for <see cref="int" />
/// </summary>
public class ExtentsInt
{
List<Tuple<int, int>> backend;
/// <summary>
/// Initialize an empty list of extents
/// Initialize an empty list of extents
/// </summary>
public ExtentsInt()
{
@@ -52,7 +52,7 @@ namespace Extents
}
/// <summary>
/// Initializes extents with an specific list
/// Initializes extents with an specific list
/// </summary>
/// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsInt(IEnumerable<Tuple<int, int>> list)
@@ -61,12 +61,12 @@ namespace Extents
}
/// <summary>
/// Gets a count of how many extents are stored
/// Gets a count of how many extents are stored
/// </summary>
public int Count => backend.Count;
/// <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>
/// <param name="item"></param>
public void Add(int item)
@@ -123,11 +123,14 @@ namespace Extents
}
/// <summary>
/// Adds a new extent
/// Adds a new extent
/// </summary>
/// <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="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</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="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)
{
int realEnd;
@@ -139,7 +142,7 @@ namespace Extents
}
/// <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>
/// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
}
/// <summary>
/// Removes all extents from this instance
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
@@ -157,7 +160,7 @@ namespace Extents
}
/// <summary>
/// Removes an item from the extents in this instance
/// Removes an item from the extents in this instance
/// </summary>
/// <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>
@@ -215,16 +218,17 @@ namespace Extents
}
/// <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>
/// <returns>Array of <see cref="Tuple"/></returns>
/// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<int, int>[] ToArray()
{
return backend.ToArray();
}
/// <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>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(int item, out int start)
{
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;
return true;
}

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="long"/>
/// Implements extents for <see cref="long" />
/// </summary>
public class ExtentsLong
{
List<Tuple<long, long>> backend;
/// <summary>
/// Initialize an empty list of extents
/// Initialize an empty list of extents
/// </summary>
public ExtentsLong()
{
@@ -52,7 +52,7 @@ namespace Extents
}
/// <summary>
/// Initializes extents with an specific list
/// Initializes extents with an specific list
/// </summary>
/// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsLong(IEnumerable<Tuple<long, long>> list)
@@ -61,12 +61,12 @@ namespace Extents
}
/// <summary>
/// Gets a count of how many extents are stored
/// Gets a count of how many extents are stored
/// </summary>
public int Count => backend.Count;
/// <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>
/// <param name="item"></param>
public void Add(long item)
@@ -123,11 +123,14 @@ namespace Extents
}
/// <summary>
/// Adds a new extent
/// Adds a new extent
/// </summary>
/// <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="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</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="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)
{
long realEnd;
@@ -139,7 +142,7 @@ namespace Extents
}
/// <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>
/// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
}
/// <summary>
/// Removes all extents from this instance
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
@@ -157,7 +160,7 @@ namespace Extents
}
/// <summary>
/// Removes an item from the extents in this instance
/// Removes an item from the extents in this instance
/// </summary>
/// <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>
@@ -215,16 +218,17 @@ namespace Extents
}
/// <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>
/// <returns>Array of <see cref="Tuple"/></returns>
/// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<long, long>[] ToArray()
{
return backend.ToArray();
}
/// <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>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(long item, out long start)
{
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;
return true;
}

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="sbyte"/>
/// Implements extents for <see cref="sbyte" />
/// </summary>
public class ExtentsSByte
{
List<Tuple<sbyte, sbyte>> backend;
/// <summary>
/// Initialize an empty list of extents
/// Initialize an empty list of extents
/// </summary>
public ExtentsSByte()
{
@@ -52,7 +52,7 @@ namespace Extents
}
/// <summary>
/// Initializes extents with an specific list
/// Initializes extents with an specific list
/// </summary>
/// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsSByte(IEnumerable<Tuple<sbyte, sbyte>> list)
@@ -61,12 +61,12 @@ namespace Extents
}
/// <summary>
/// Gets a count of how many extents are stored
/// Gets a count of how many extents are stored
/// </summary>
public int Count => backend.Count;
/// <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>
/// <param name="item"></param>
public void Add(sbyte item)
@@ -123,11 +123,14 @@ namespace Extents
}
/// <summary>
/// Adds a new extent
/// Adds a new extent
/// </summary>
/// <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="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</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="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)
{
sbyte realEnd;
@@ -139,7 +142,7 @@ namespace Extents
}
/// <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>
/// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
}
/// <summary>
/// Removes all extents from this instance
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
@@ -157,7 +160,7 @@ namespace Extents
}
/// <summary>
/// Removes an item from the extents in this instance
/// Removes an item from the extents in this instance
/// </summary>
/// <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>
@@ -215,16 +218,17 @@ namespace Extents
}
/// <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>
/// <returns>Array of <see cref="Tuple"/></returns>
/// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<sbyte, sbyte>[] ToArray()
{
return backend.ToArray();
}
/// <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>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(sbyte item, out sbyte start)
{
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;
return true;
}

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="short"/>
/// Implements extents for <see cref="short" />
/// </summary>
public class ExtentsShort
{
List<Tuple<short, short>> backend;
/// <summary>
/// Initialize an empty list of extents
/// Initialize an empty list of extents
/// </summary>
public ExtentsShort()
{
@@ -52,7 +52,7 @@ namespace Extents
}
/// <summary>
/// Initializes extents with an specific list
/// Initializes extents with an specific list
/// </summary>
/// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsShort(IEnumerable<Tuple<short, short>> list)
@@ -61,12 +61,12 @@ namespace Extents
}
/// <summary>
/// Gets a count of how many extents are stored
/// Gets a count of how many extents are stored
/// </summary>
public int Count => backend.Count;
/// <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>
/// <param name="item"></param>
public void Add(short item)
@@ -123,11 +123,14 @@ namespace Extents
}
/// <summary>
/// Adds a new extent
/// Adds a new extent
/// </summary>
/// <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="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</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="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)
{
short realEnd;
@@ -139,7 +142,7 @@ namespace Extents
}
/// <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>
/// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
}
/// <summary>
/// Removes all extents from this instance
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
@@ -157,7 +160,7 @@ namespace Extents
}
/// <summary>
/// Removes an item from the extents in this instance
/// Removes an item from the extents in this instance
/// </summary>
/// <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>
@@ -215,16 +218,17 @@ namespace Extents
}
/// <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>
/// <returns>Array of <see cref="Tuple"/></returns>
/// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<short, short>[] ToArray()
{
return backend.ToArray();
}
/// <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>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(short item, out short start)
{
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;
return true;
}

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="uint"/>
/// Implements extents for <see cref="uint" />
/// </summary>
public class ExtentsUInt
{
List<Tuple<uint, uint>> backend;
/// <summary>
/// Initialize an empty list of extents
/// Initialize an empty list of extents
/// </summary>
public ExtentsUInt()
{
@@ -52,7 +52,7 @@ namespace Extents
}
/// <summary>
/// Initializes extents with an specific list
/// Initializes extents with an specific list
/// </summary>
/// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsUInt(IEnumerable<Tuple<uint, uint>> list)
@@ -61,12 +61,12 @@ namespace Extents
}
/// <summary>
/// Gets a count of how many extents are stored
/// Gets a count of how many extents are stored
/// </summary>
public int Count => backend.Count;
/// <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>
/// <param name="item"></param>
public void Add(uint item)
@@ -123,11 +123,14 @@ namespace Extents
}
/// <summary>
/// Adds a new extent
/// Adds a new extent
/// </summary>
/// <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="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</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="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)
{
uint realEnd;
@@ -139,7 +142,7 @@ namespace Extents
}
/// <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>
/// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
}
/// <summary>
/// Removes all extents from this instance
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
@@ -157,7 +160,7 @@ namespace Extents
}
/// <summary>
/// Removes an item from the extents in this instance
/// Removes an item from the extents in this instance
/// </summary>
/// <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>
@@ -215,16 +218,17 @@ namespace Extents
}
/// <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>
/// <returns>Array of <see cref="Tuple"/></returns>
/// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<uint, uint>[] ToArray()
{
return backend.ToArray();
}
/// <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>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(uint item, out uint start)
{
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;
return true;
}

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="ulong"/>
/// Implements extents for <see cref="ulong" />
/// </summary>
public class ExtentsULong
{
List<Tuple<ulong, ulong>> backend;
/// <summary>
/// Initialize an empty list of extents
/// Initialize an empty list of extents
/// </summary>
public ExtentsULong()
{
@@ -52,7 +52,7 @@ namespace Extents
}
/// <summary>
/// Initializes extents with an specific list
/// Initializes extents with an specific list
/// </summary>
/// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsULong(IEnumerable<Tuple<ulong, ulong>> list)
@@ -61,12 +61,12 @@ namespace Extents
}
/// <summary>
/// Gets a count of how many extents are stored
/// Gets a count of how many extents are stored
/// </summary>
public int Count => backend.Count;
/// <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>
/// <param name="item"></param>
public void Add(ulong item)
@@ -123,11 +123,14 @@ namespace Extents
}
/// <summary>
/// Adds a new extent
/// Adds a new extent
/// </summary>
/// <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="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</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="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)
{
ulong realEnd;
@@ -139,7 +142,7 @@ namespace Extents
}
/// <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>
/// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
}
/// <summary>
/// Removes all extents from this instance
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
@@ -157,7 +160,7 @@ namespace Extents
}
/// <summary>
/// Removes an item from the extents in this instance
/// Removes an item from the extents in this instance
/// </summary>
/// <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>
@@ -215,16 +218,17 @@ namespace Extents
}
/// <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>
/// <returns>Array of <see cref="Tuple"/></returns>
/// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<ulong, ulong>[] ToArray()
{
return backend.ToArray();
}
/// <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>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
@@ -232,7 +236,8 @@ namespace Extents
public bool GetStart(ulong item, out ulong start)
{
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;
return true;
}

View File

@@ -37,14 +37,14 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="ushort"/>
/// Implements extents for <see cref="ushort" />
/// </summary>
public class ExtentsUShort
{
List<Tuple<ushort, ushort>> backend;
/// <summary>
/// Initialize an empty list of extents
/// Initialize an empty list of extents
/// </summary>
public ExtentsUShort()
{
@@ -52,7 +52,7 @@ namespace Extents
}
/// <summary>
/// Initializes extents with an specific list
/// Initializes extents with an specific list
/// </summary>
/// <param name="list">List of extents as tuples "start, end"</param>
public ExtentsUShort(IEnumerable<Tuple<ushort, ushort>> list)
@@ -61,12 +61,12 @@ namespace Extents
}
/// <summary>
/// Gets a count of how many extents are stored
/// Gets a count of how many extents are stored
/// </summary>
public int Count => backend.Count;
/// <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>
/// <param name="item"></param>
public void Add(ushort item)
@@ -123,11 +123,14 @@ namespace Extents
}
/// <summary>
/// Adds a new extent
/// Adds a new extent
/// </summary>
/// <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="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</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="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)
{
ushort realEnd;
@@ -139,7 +142,7 @@ namespace Extents
}
/// <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>
/// <param name="item">Item to seach for</param>
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
@@ -149,7 +152,7 @@ namespace Extents
}
/// <summary>
/// Removes all extents from this instance
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
@@ -157,7 +160,7 @@ namespace Extents
}
/// <summary>
/// Removes an item from the extents in this instance
/// Removes an item from the extents in this instance
/// </summary>
/// <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>
@@ -215,16 +218,17 @@ namespace Extents
}
/// <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>
/// <returns>Array of <see cref="Tuple"/></returns>
/// <returns>Array of <see cref="Tuple" /></returns>
public Tuple<ushort, ushort>[] ToArray()
{
return backend.ToArray();
}
/// <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>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
@@ -232,7 +236,9 @@ namespace Extents
public bool GetStart(ushort item, out ushort start)
{
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;
return true;
}

View File

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

View File

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

View File

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