diff --git a/src/Hst.Imager.ConsoleApp/CommandHandler.cs b/src/Hst.Imager.ConsoleApp/CommandHandler.cs index 008ae24..33aee6d 100644 --- a/src/Hst.Imager.ConsoleApp/CommandHandler.cs +++ b/src/Hst.Imager.ConsoleApp/CommandHandler.cs @@ -50,8 +50,34 @@ private static async Task> GetPhysicalDrives() return (await physicalDriveManager.GetPhysicalDrives()).ToList(); } + private static readonly Regex IntRegex = + new("^(\\d+)$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + + private static readonly Regex HexRegex = + new("^0x([\\da-f])+$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + + private static uint? ParseHexOrIntegerValue(string value) + { + if (string.IsNullOrWhiteSpace(value)) + { + return null; + } + + if (HexRegex.IsMatch(value)) + { + return System.Convert.ToUInt32(value, 16); + } + + if (IntRegex.IsMatch(value) && uint.TryParse(value, out var uintValue)) + { + return uintValue; + } + + throw new ArgumentException("Invalid hex or integer value", nameof(value)); + } + private static readonly Regex SizeUnitRegex = - new("(\\d+)([\\.]{1}\\d+)?(kb|mb|gb|%)?$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + new("^(\\d+)([\\.]{1}\\d+)?(kb|mb|gb|%)?$", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static Size ParseSize(string size) { @@ -291,22 +317,25 @@ await Execute(new RdbFsUpdateCommand(GetLogger(), GetCommand await GetPhysicalDrives(), path, fileSystemNumber, dosType, fileSystemName, fileSystemPath)); } - public static async Task RdbPartAdd(string path, string name, string dosType, string size, int reserved, - int preAlloc, int buffers, int maxTransfer, bool noMount, bool bootable, int priority, int fileSystemBlockSize) + public static async Task RdbPartAdd(string path, string name, string dosType, string size, uint? reserved, + uint? preAlloc, uint? buffers, string maxTransfer, string mask, bool noMount, bool bootable, int priority, + int fileSystemBlockSize) { await Execute(new RdbPartAddCommand(GetLogger(), GetCommandHelper(), await GetPhysicalDrives(), path, name, dosType, ParseSize(size), reserved, preAlloc, buffers, - maxTransfer, noMount, bootable, priority, fileSystemBlockSize)); + ParseHexOrIntegerValue(maxTransfer), ParseHexOrIntegerValue(mask), noMount, bootable, priority, + fileSystemBlockSize)); } public static async Task RdbPartUpdate(string path, int partitionNumber, string name, string dosType, int? reserved, - int? preAlloc, int? buffers, uint? maxTransfer, uint? mask, bool? noMount, bool? bootable, + int? preAlloc, int? buffers, string maxTransfer, string mask, bool? noMount, bool? bootable, int? bootPriority, int? fileSystemBlockSize) { await Execute(new RdbPartUpdateCommand(GetLogger(), GetCommandHelper(), await GetPhysicalDrives(), path, partitionNumber, name, dosType, reserved, preAlloc, buffers, - maxTransfer, mask, noMount, bootable, bootPriority, fileSystemBlockSize)); + ParseHexOrIntegerValue(maxTransfer), ParseHexOrIntegerValue(mask), noMount, bootable, bootPriority, + fileSystemBlockSize)); } public static async Task RdbPartDel(string path, int partitionNumber) diff --git a/src/Hst.Imager.ConsoleApp/Presenters/RdbInfoPresenter.cs b/src/Hst.Imager.ConsoleApp/Presenters/RdbInfoPresenter.cs index 34194b2..f508f30 100644 --- a/src/Hst.Imager.ConsoleApp/Presenters/RdbInfoPresenter.cs +++ b/src/Hst.Imager.ConsoleApp/Presenters/RdbInfoPresenter.cs @@ -2,8 +2,10 @@ { using System.Linq; using System.Text; + using Amiga.Extensions; using Core.Commands; using Core.Extensions; + using Hst.Core.Extensions; public static class RigidDiskBlockPresenter { @@ -82,7 +84,7 @@ public static string Present(RdbInfo rdbInfo) Columns = new[] { (++fileSystemNumber).ToString(), - $"0x{x.DosType.FormatHex().ToUpper()}, {x.DosTypeFormatted}", + $"0x{x.DosType.FormatHex().ToUpper()} ({x.DosType.FormatDosType()})", x.VersionFormatted, x.FileSystemName ?? string.Empty, ((long)x.FileSystemSize).FormatBytes() @@ -128,9 +130,9 @@ public static string Present(RdbInfo rdbInfo) x.DriveName, x.PartitionSize.FormatBytes(), x.LowCyl.ToString(), x.HighCyl.ToString(), x.Reserved.ToString(), x.PreAlloc.ToString(), x.FileSystemBlockSize.ToString(), x.NumBuffer.ToString(), - $"0x{x.DosType.FormatHex().ToUpper()}, {x.DosTypeFormatted}", - $"0x{x.MaxTransfer.FormatHex().ToUpper()}, {x.MaxTransfer}", - $"0x{x.Mask.FormatHex().ToUpper()}, {x.Mask}", + $"0x{x.DosType.FormatHex().ToUpper()} ({x.DosTypeFormatted})", + $"0x{x.MaxTransfer.FormatHex().ToUpper()} ({x.MaxTransfer})", + $"0x{x.Mask.FormatHex().ToUpper()} ({x.Mask})", x.Bootable.ToString(), x.NoMount.ToString(), x.BootPriority.ToString() } diff --git a/src/Hst.Imager.ConsoleApp/RdbCommandFactory.cs b/src/Hst.Imager.ConsoleApp/RdbCommandFactory.cs index 1a4a037..8a8c5e7 100644 --- a/src/Hst.Imager.ConsoleApp/RdbCommandFactory.cs +++ b/src/Hst.Imager.ConsoleApp/RdbCommandFactory.cs @@ -246,25 +246,25 @@ private static Command CreateRdbPartAdd() name: "Size", description: "Size of the partition."); - var reservedOption = new Option( + var reservedOption = new Option( new[] { "--reserved", "-r" }, - description: "Set reserved blocks at start of partition.", - getDefaultValue: () => 2); + description: "Set reserved blocks at start of partition."); - var preAllocOption = new Option( + var preAllocOption = new Option( new[] { "--pre-alloc", "-pa" }, - description: "Set reserved blocks at end of partition", - getDefaultValue: () => 5); + description: "Set reserved blocks at end of partition"); - var buffersOption = new Option( + var buffersOption = new Option( new[] { "--buffers", "-bu" }, - description: "Set buffers", - getDefaultValue: () => 30); + description: "Set buffers"); - var maxTransferOption = new Option( + var maxTransferOption = new Option( new[] { "--max-transfer", "-mt" }, - description: "Set buffers", - getDefaultValue: () => 130560); + description: "Set buffers"); + + var maskOption = new Option( + new[] { "--mask", "-ma" }, + description: "Mask"); var noMountOption = new Option( new[] { "--no-mount", "-nm" }, @@ -297,12 +297,13 @@ private static Command CreateRdbPartAdd() var preAlloc = context.ParseResult.GetValueForOption(preAllocOption); var buffers = context.ParseResult.GetValueForOption(buffersOption); var maxTransfer = context.ParseResult.GetValueForOption(maxTransferOption); + var mask = context.ParseResult.GetValueForOption(maskOption); var noMount = context.ParseResult.GetValueForOption(noMountOption); var bootable = context.ParseResult.GetValueForOption(bootableOption); var priority = context.ParseResult.GetValueForOption(priorityOption); var blockSize = context.ParseResult.GetValueForOption(blockSizeOption); - await CommandHandler.RdbPartAdd(path, name, dosType, size, reserved, preAlloc, buffers, maxTransfer, + await CommandHandler.RdbPartAdd(path, name, dosType, size, reserved, preAlloc, buffers, maxTransfer, mask, noMount, bootable, priority, blockSize); }); @@ -314,6 +315,7 @@ await CommandHandler.RdbPartAdd(path, name, dosType, size, reserved, preAlloc, b rdbPartAddCommand.AddOption(preAllocOption); rdbPartAddCommand.AddOption(buffersOption); rdbPartAddCommand.AddOption(maxTransferOption); + rdbPartAddCommand.AddOption(maskOption); rdbPartAddCommand.AddOption(noMountOption); rdbPartAddCommand.AddOption(bootableOption); rdbPartAddCommand.AddOption(priorityOption); @@ -352,11 +354,11 @@ private static Command CreateRdbPartUpdate() new[] { "--buffers", "-bu" }, description: "Buffers"); - var maxTransferOption = new Option( + var maxTransferOption = new Option( new[] { "--max-transfer", "-mt" }, description: "Max transfer"); - var maskOption = new Option( + var maskOption = new Option( new[] { "--mask", "-ma" }, description: "Mask"); @@ -407,6 +409,7 @@ await CommandHandler.RdbPartUpdate(path, partitionNumber, name, dosType, reserve command.AddOption(preAllocOption); command.AddOption(buffersOption); command.AddOption(maxTransferOption); + command.AddOption(maskOption); command.AddOption(noMountOption); command.AddOption(bootableOption); command.AddOption(priorityOption); diff --git a/src/Hst.Imager.Core/Commands/RdbFsAddCommand.cs b/src/Hst.Imager.Core/Commands/RdbFsAddCommand.cs index 0d8815c..ea16760 100644 --- a/src/Hst.Imager.Core/Commands/RdbFsAddCommand.cs +++ b/src/Hst.Imager.Core/Commands/RdbFsAddCommand.cs @@ -106,7 +106,7 @@ public override async Task Execute(CancellationToken token) long size = fileSystemHeaderBlock.FileSystemSize; OnInformationMessage("Adding file system:"); - OnInformationMessage($"- DOS type '{fileSystemHeaderBlock.DosType.FormatDosType()}'"); + OnInformationMessage($"- DOS type '0x{fileSystemHeaderBlock.DosType.FormatHex()}' ({fileSystemHeaderBlock.DosType.FormatDosType()})"); OnInformationMessage($"- Version '{fileSystemHeaderBlock.VersionFormatted}'"); OnInformationMessage($"- Size '{size.FormatBytes()}' ({size} bytes)"); OnInformationMessage($"- File system name '{fileSystemHeaderBlock.FileSystemName}'"); diff --git a/src/Hst.Imager.Core/Commands/RdbFsExportCommand.cs b/src/Hst.Imager.Core/Commands/RdbFsExportCommand.cs index 80e96cc..8124f5b 100644 --- a/src/Hst.Imager.Core/Commands/RdbFsExportCommand.cs +++ b/src/Hst.Imager.Core/Commands/RdbFsExportCommand.cs @@ -8,6 +8,7 @@ using Amiga.Extensions; using Extensions; using Hst.Core; +using Hst.Core.Extensions; using Microsoft.Extensions.Logging; public class RdbFsExportCommand : CommandBase @@ -67,7 +68,7 @@ public override async Task Execute(CancellationToken token) var fileSystemBytes = fileSystemHeaderBlock.LoadSegBlocks.SelectMany(x => x.Data).ToArray(); long fileSystemSize = fileSystemBytes.Length; - OnDebugMessage($"DOS type '{fileSystemHeaderBlock.DosType.FormatDosType()}' {fileSystemSize.FormatBytes()} ({fileSystemSize} bytes)"); + OnDebugMessage($"DOS type '0x{fileSystemHeaderBlock.DosType.FormatHex()}' ({fileSystemHeaderBlock.DosType.FormatDosType()})"); OnDebugMessage($"Version '{fileSystemHeaderBlock.VersionFormatted}'"); OnDebugMessage($"Size '{fileSystemSize.FormatBytes()}' ({fileSystemSize} bytes)"); OnDebugMessage($"File system name '{fileSystemHeaderBlock.FileSystemName}'"); diff --git a/src/Hst.Imager.Core/Commands/RdbFsImportCommand.cs b/src/Hst.Imager.Core/Commands/RdbFsImportCommand.cs index 22e9e14..ceb79da 100644 --- a/src/Hst.Imager.Core/Commands/RdbFsImportCommand.cs +++ b/src/Hst.Imager.Core/Commands/RdbFsImportCommand.cs @@ -94,7 +94,7 @@ public override async Task Execute(CancellationToken token) { long size = fileSystemHeaderBlock.FileSystemSize; OnInformationMessage("Imported file system:"); - OnInformationMessage($"- DOS type '{fileSystemHeaderBlock.DosType.FormatDosType()}'"); + OnInformationMessage($"- DOS type '0x{fileSystemHeaderBlock.DosType.FormatHex()}' ({fileSystemHeaderBlock.DosType.FormatDosType()})"); OnInformationMessage($"- Version '{fileSystemHeaderBlock.VersionFormatted}'"); OnInformationMessage($"- Size '{size.FormatBytes()}' ({size} bytes)"); OnInformationMessage($"- File system name '{fileSystemHeaderBlock.FileSystemName}'"); diff --git a/src/Hst.Imager.Core/Commands/RdbFsUpdateCommand.cs b/src/Hst.Imager.Core/Commands/RdbFsUpdateCommand.cs index d37cb04..3a3d26e 100644 --- a/src/Hst.Imager.Core/Commands/RdbFsUpdateCommand.cs +++ b/src/Hst.Imager.Core/Commands/RdbFsUpdateCommand.cs @@ -85,7 +85,7 @@ public override async Task Execute(CancellationToken token) fileSystemHeaderBlock.DosType = dosTypeBytes; - OnInformationMessage($"DOS type '{fileSystemHeaderBlock.DosType.FormatDosType()}'"); + OnInformationMessage($"DOS type '0x{fileSystemHeaderBlock.DosType.FormatHex()}' ({fileSystemHeaderBlock.DosType.FormatDosType()})"); } if (!string.IsNullOrEmpty(fileSystemName)) diff --git a/src/Hst.Imager.Core/Commands/RdbPartAddCommand.cs b/src/Hst.Imager.Core/Commands/RdbPartAddCommand.cs index c3c5c85..b1d5d4a 100644 --- a/src/Hst.Imager.Core/Commands/RdbPartAddCommand.cs +++ b/src/Hst.Imager.Core/Commands/RdbPartAddCommand.cs @@ -9,6 +9,7 @@ using Amiga; using Amiga.RigidDiskBlocks; using Hst.Core; + using Hst.Core.Extensions; using Microsoft.Extensions.Logging; using Size = Models.Size; using PartitionBlock = Amiga.RigidDiskBlocks.PartitionBlock; @@ -22,10 +23,11 @@ public class RdbPartAddCommand : CommandBase private readonly string path; private readonly string name; private readonly Size size; - private readonly int reserved; - private readonly int preAlloc; - private readonly int buffers; - private readonly int maxTransfer; + private readonly uint? reserved; + private readonly uint? preAlloc; + private readonly uint? buffers; + private readonly uint? maxTransfer; + private readonly uint? mask; private readonly string dosType; private readonly bool noMount; private readonly bool bootable; @@ -34,7 +36,7 @@ public class RdbPartAddCommand : CommandBase public RdbPartAddCommand(ILogger logger, ICommandHelper commandHelper, IEnumerable physicalDrives, string path, string name, string dosType, Size size, - int reserved, int preAlloc, int buffers, int maxTransfer, bool noMount, bool bootable, int priority, int fileSystemBlockSize) + uint? reserved, uint? preAlloc, uint? buffers, uint? maxTransfer, uint? mask, bool noMount, bool bootable, int priority, int fileSystemBlockSize) { this.logger = logger; this.commandHelper = commandHelper; @@ -46,6 +48,7 @@ public RdbPartAddCommand(ILogger logger, ICommandHelper comma this.preAlloc = preAlloc; this.buffers = buffers; this.maxTransfer = maxTransfer; + this.mask = mask; this.dosType = dosType; this.noMount = noMount; this.bootable = bootable; @@ -130,10 +133,31 @@ public override async Task Execute(CancellationToken token) flags += (int)PartitionBlock.PartitionFlagsEnum.NoMount; } - partitionBlock.Reserved = (uint)reserved; - partitionBlock.PreAlloc = (uint)preAlloc; - partitionBlock.MaxTransfer = (uint)maxTransfer; - partitionBlock.NumBuffer = (uint)buffers; + if (reserved.HasValue) + { + partitionBlock.Reserved = reserved.Value; + } + + if (preAlloc.HasValue) + { + partitionBlock.PreAlloc = preAlloc.Value; + } + + if (maxTransfer.HasValue) + { + partitionBlock.MaxTransfer = maxTransfer.Value; + } + + if (mask.HasValue) + { + partitionBlock.Mask = mask.Value; + } + + if (buffers.HasValue) + { + partitionBlock.NumBuffer = buffers.Value; + } + partitionBlock.Flags = flags; partitionBlock.BootPriority = (uint)priority; partitionBlock.SizeBlock = rigidDiskBlock.BlockSize / SizeOf.ULong; @@ -144,7 +168,8 @@ public override async Task Execute(CancellationToken token) OnInformationMessage($"- Reserved '{partitionBlock.Reserved}'"); OnInformationMessage($"- PreAlloc '{partitionBlock.PreAlloc}'"); OnInformationMessage($"- Buffers '{partitionBlock.NumBuffer}'"); - OnInformationMessage($"- Max Transfer '{partitionBlock.MaxTransfer}'"); + OnInformationMessage($"- Max Transfer '0x{partitionBlock.MaxTransfer.FormatHex().ToUpper()}' ({partitionBlock.MaxTransfer})"); + OnInformationMessage($"- Mask '0x{partitionBlock.Mask.FormatHex().ToUpper()}' ({partitionBlock.Mask})"); OnInformationMessage($"- File System Block Size '{partitionBlock.Sectors * rigidDiskBlock.BlockSize}'"); rigidDiskBlock.PartitionBlocks = rigidDiskBlock.PartitionBlocks.Concat(new[] { partitionBlock }); diff --git a/src/Hst.Imager.Core/Commands/RdbPartFormatCommand.cs b/src/Hst.Imager.Core/Commands/RdbPartFormatCommand.cs index 1df58d3..9dde7fc 100644 --- a/src/Hst.Imager.Core/Commands/RdbPartFormatCommand.cs +++ b/src/Hst.Imager.Core/Commands/RdbPartFormatCommand.cs @@ -4,9 +4,11 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; + using Amiga.Extensions; using Amiga.FileSystems.FastFileSystem; using Amiga.FileSystems.Pfs3; using Hst.Core; + using Hst.Core.Extensions; using Microsoft.Extensions.Logging; public class RdbPartFormatCommand : CommandBase @@ -65,7 +67,7 @@ public override async Task Execute(CancellationToken token) var partitionBlock = partitionBlocks[partitionNumber - 1]; OnInformationMessage($"- Name '{partitionBlock.DriveName}'"); - OnInformationMessage($"- DOS type '{partitionBlock.DosTypeFormatted}'"); + OnInformationMessage($"- DOS type '0x{partitionBlock.DosType.FormatHex()}' ({partitionBlock.DosType.FormatDosType()})"); OnInformationMessage($"- Volume name '{name}'"); switch (partitionBlock.DosTypeFormatted) diff --git a/src/Hst.Imager.Core/Commands/RdbPartUpdateCommand.cs b/src/Hst.Imager.Core/Commands/RdbPartUpdateCommand.cs index 39680a9..82eb11b 100644 --- a/src/Hst.Imager.Core/Commands/RdbPartUpdateCommand.cs +++ b/src/Hst.Imager.Core/Commands/RdbPartUpdateCommand.cs @@ -4,10 +4,10 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; - using Extensions; - using Hst.Amiga; - using Hst.Amiga.RigidDiskBlocks; + using Amiga; + using Amiga.RigidDiskBlocks; using Hst.Core; + using Hst.Core.Extensions; using Microsoft.Extensions.Logging; public class RdbPartUpdateCommand : CommandBase @@ -116,7 +116,7 @@ public override async Task Execute(CancellationToken token) partitionBlock.DosType = dosTypeBytes; hasChanges = true; - OnDebugMessage( + OnInformationMessage( $"DOS Type '0x{partitionBlock.DosType.FormatHex().ToUpper()}, {partitionBlock.DosTypeFormatted}'"); } @@ -132,7 +132,7 @@ public override async Task Execute(CancellationToken token) partitionBlock.DriveName = name; hasChanges = true; - OnDebugMessage($"Drive name '{name}'"); + OnInformationMessage($"Drive name '{name}'"); } var flags = partitionBlock.Flags; @@ -150,7 +150,7 @@ public override async Task Execute(CancellationToken token) } hasChanges = true; - OnDebugMessage($"Bootable '{(flags & (int)PartitionBlock.PartitionFlagsEnum.Bootable) == (int)PartitionBlock.PartitionFlagsEnum.Bootable}'"); + OnInformationMessage($"Bootable '{(flags & (int)PartitionBlock.PartitionFlagsEnum.Bootable) == (int)PartitionBlock.PartitionFlagsEnum.Bootable}'"); } // update no mount @@ -166,7 +166,7 @@ public override async Task Execute(CancellationToken token) } hasChanges = true; - OnDebugMessage($"Bootable '{(flags & (int)PartitionBlock.PartitionFlagsEnum.NoMount) == (int)PartitionBlock.PartitionFlagsEnum.NoMount}'"); + OnInformationMessage($"Bootable '{(flags & (int)PartitionBlock.PartitionFlagsEnum.NoMount) == (int)PartitionBlock.PartitionFlagsEnum.NoMount}'"); } // update flags, if changed @@ -180,7 +180,7 @@ public override async Task Execute(CancellationToken token) { partitionBlock.Reserved = (uint)reserved; hasChanges = true; - OnDebugMessage($"Reserved '{partitionBlock.Reserved}'"); + OnInformationMessage($"Reserved '{partitionBlock.Reserved}'"); } // update prealloc @@ -188,7 +188,7 @@ public override async Task Execute(CancellationToken token) { partitionBlock.PreAlloc = (uint)preAlloc; hasChanges = true; - OnDebugMessage($"PreAlloc '{partitionBlock.PreAlloc}'"); + OnInformationMessage($"PreAlloc '{partitionBlock.PreAlloc}'"); } // update buffers @@ -196,7 +196,7 @@ public override async Task Execute(CancellationToken token) { partitionBlock.NumBuffer = (uint)buffers; hasChanges = true; - OnDebugMessage($"Buffers '{partitionBlock.NumBuffer}'"); + OnInformationMessage($"Buffers '{partitionBlock.NumBuffer}'"); } // update max transfer @@ -204,7 +204,7 @@ public override async Task Execute(CancellationToken token) { partitionBlock.MaxTransfer = maxTransfer.Value; hasChanges = true; - OnDebugMessage($"Max Transfer '0x{partitionBlock.MaxTransfer.FormatHex().ToUpper()}, {partitionBlock.MaxTransfer}'"); + OnInformationMessage($"Max Transfer '0x{partitionBlock.MaxTransfer.FormatHex().ToUpper()}' ({partitionBlock.MaxTransfer})"); } // update mask @@ -212,7 +212,7 @@ public override async Task Execute(CancellationToken token) { partitionBlock.Mask = mask.Value; hasChanges = true; - OnDebugMessage($"Mask '0x{partitionBlock.Mask.FormatHex().ToUpper()}, {partitionBlock.Mask}'"); + OnInformationMessage($"Mask '0x{partitionBlock.Mask.FormatHex().ToUpper()}' ({partitionBlock.Mask})"); } // update boot priority @@ -220,7 +220,7 @@ public override async Task Execute(CancellationToken token) { partitionBlock.BootPriority = (uint)bootPriority; hasChanges = true; - OnDebugMessage($"Boot priority '{partitionBlock.BootPriority}'"); + OnInformationMessage($"Boot priority '{partitionBlock.BootPriority}'"); } // update file system block size @@ -228,7 +228,7 @@ public override async Task Execute(CancellationToken token) { partitionBlock.Sectors = (uint)(fileSystemBlockSize / rigidDiskBlock.BlockSize); hasChanges = true; - OnDebugMessage($"File system block size '{fileSystemBlockSize}'"); + OnInformationMessage($"File system block size '{fileSystemBlockSize}'"); } if (!hasChanges) diff --git a/src/Hst.Imager.Core/Extensions/FormatExtensions.cs b/src/Hst.Imager.Core/Extensions/FormatExtensions.cs index afc6f87..1240d85 100644 --- a/src/Hst.Imager.Core/Extensions/FormatExtensions.cs +++ b/src/Hst.Imager.Core/Extensions/FormatExtensions.cs @@ -1,7 +1,6 @@ namespace Hst.Imager.Core.Extensions { using System; - using System.Linq; public static class FormatExtensions { @@ -16,18 +15,6 @@ public static string FormatBytes(this long size, int precision = 1, string forma $" {formattedUnit}"); } - public static string FormatHex(this byte[] bytes) - { - return string.Join("", bytes.Select(x => $"{x:x2}")); - } - - public static string FormatHex(this uint value) - { - var bytes = BitConverter.GetBytes(value); - Array.Reverse(bytes); - return bytes.FormatHex(); - } - public static string FormatElapsed(this TimeSpan value) { return $"{Convert.ToInt32(Math.Floor(value.TotalHours))}h:{value.Minutes:D2}m:{value.Seconds:D2}s";