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>