mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Code reformat.
This commit is contained in:
28
ArrayFill.cs
28
ArrayFill.cs
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user