Code reformat.

This commit is contained in:
2019-11-25 00:54:39 +00:00
parent 6937468728
commit a7d7c673a1
13 changed files with 356 additions and 392 deletions

View File

@@ -31,27 +31,23 @@ namespace DiscImageChef
{
public static partial class ArrayHelpers
{
/// <summary>
/// Fills an array with the specified value
/// </summary>
/// <summary>Fills an array with the specified value</summary>
/// <param name="destinationArray">Array</param>
/// <param name="value">Value</param>
/// <typeparam name="T">Array type</typeparam>
public static void ArrayFill<T>(T[] destinationArray, T value)
public static void ArrayFill<T>(T[] destinationArray, T value) => ArrayFill(destinationArray, new[]
{
// if called with a single value, wrap the value in an array and call the main function
ArrayFill(destinationArray, new[] {value});
}
value
});
/// <summary>
/// Fills an array with the contents of the specified array
/// </summary>
/// <summary>Fills an array with the contents of the specified array</summary>
/// <param name="destinationArray">Array</param>
/// <param name="value">Value</param>
/// <typeparam name="T">Array type</typeparam>
public static void ArrayFill<T>(T[] destinationArray, T[] value)
{
if(destinationArray == null) throw new ArgumentNullException(nameof(destinationArray));
if(destinationArray == null)
throw new ArgumentNullException(nameof(destinationArray));
if(value.Length > destinationArray.Length)
throw new ArgumentException("Length of value array must not be more than length of destination");
@@ -68,16 +64,16 @@ namespace DiscImageChef
Array.Copy(destinationArray, 0, destinationArray, copyLength, destinationArray.Length - copyLength);
}
/// <summary>
/// Converts a byte array to its hexadecimal representation
/// </summary>
/// <summary>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>
/// <returns></returns>
public static string ByteArrayToHex(byte[] array, bool upper = false)
{
StringBuilder sb = new StringBuilder();
for(long i = 0; i < array.LongLength; i++) sb.AppendFormat("{0:x2}", array[i]);
var sb = new StringBuilder();
for(long i = 0; i < array.LongLength; i++)
sb.AppendFormat("{0:x2}", array[i]);
return upper ? sb.ToString().ToUpper() : sb.ToString();
}