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

@@ -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,7 +62,8 @@ 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);
}

View File

@@ -177,7 +177,10 @@ namespace DiscImageChef
/// <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>
/// <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();
@@ -191,21 +194,31 @@ namespace DiscImageChef
/// <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>
/// <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();
@@ -219,7 +232,10 @@ namespace DiscImageChef
/// <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
@@ -233,9 +249,15 @@ namespace DiscImageChef
/// <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>
/// <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
@@ -249,9 +271,15 @@ namespace DiscImageChef
/// <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>
/// <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>
/// <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
@@ -326,7 +382,10 @@ namespace DiscImageChef
/// <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
@@ -340,9 +399,15 @@ namespace DiscImageChef
/// <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
@@ -356,9 +421,15 @@ namespace DiscImageChef
/// <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

@@ -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);",

View File

@@ -126,7 +126,10 @@ namespace Extents
/// 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="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)
{
@@ -215,7 +218,8 @@ 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>
public Tuple<byte, byte>[] ToArray()
@@ -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

@@ -126,7 +126,10 @@ namespace Extents
/// 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="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)
{
@@ -215,7 +218,8 @@ 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>
public Tuple<int, int>[] ToArray()
@@ -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

@@ -126,7 +126,10 @@ namespace Extents
/// 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="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)
{
@@ -215,7 +218,8 @@ 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>
public Tuple<long, long>[] ToArray()
@@ -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

@@ -126,7 +126,10 @@ namespace Extents
/// 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="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)
{
@@ -215,7 +218,8 @@ 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>
public Tuple<sbyte, sbyte>[] ToArray()
@@ -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

@@ -126,7 +126,10 @@ namespace Extents
/// 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="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)
{
@@ -215,7 +218,8 @@ 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>
public Tuple<short, short>[] ToArray()
@@ -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

@@ -126,7 +126,10 @@ namespace Extents
/// 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="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)
{
@@ -215,7 +218,8 @@ 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>
public Tuple<uint, uint>[] ToArray()
@@ -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

@@ -126,7 +126,10 @@ namespace Extents
/// 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="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)
{
@@ -215,7 +218,8 @@ 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>
public Tuple<ulong, ulong>[] ToArray()
@@ -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

@@ -126,7 +126,10 @@ namespace Extents
/// 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="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)
{
@@ -215,7 +218,8 @@ 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>
public Tuple<ushort, ushort>[] ToArray()
@@ -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;
}