-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
280 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using ExtSort.Services.Factories; | ||
|
||
using System.CommandLine.Parsing; | ||
|
||
namespace ExtSort.Models.Binders | ||
{ | ||
internal record EvaluatorBinder() | ||
{ | ||
public EvaluatorBinder(ParseResult parser) : this() | ||
{ | ||
var args = ArgumentFactory.EvaluatorArguments.Value; | ||
|
||
if (!int.TryParse(parser.GetValueForArgument(args[nameof(DiskLatencyMs)])?.ToString(), out var diskLatencyMs)) | ||
throw new InvalidCastException("The size of RAM available is in incorrect format."); | ||
if (!int.TryParse(parser.GetValueForArgument(args[nameof(DiskRandomReadSpeedMbs)])?.ToString(), out var diskRandomReadSpeedMbs)) | ||
throw new InvalidCastException("The size of RAM available is in incorrect format."); | ||
|
||
FileSizeMb = (int)parser.GetValueForArgument(args[nameof(FileSizeMb)]); | ||
RamAvailableMb = (int)parser.GetValueForArgument(args[nameof(RamAvailableMb)]); | ||
NumberOfFiles = (int)parser.GetValueForArgument(args[nameof(NumberOfFiles)]); | ||
|
||
DiskLatencyMs = diskLatencyMs; | ||
DiskRandomReadSpeedMbs = diskRandomReadSpeedMbs; | ||
} | ||
|
||
public int FileSizeMb { get; init; } | ||
public int RamAvailableMb { get; init; } | ||
public int NumberOfFiles { get; init; } | ||
public int DiskLatencyMs { get; init; } | ||
public int DiskRandomReadSpeedMbs { get; init; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using ExtSort.Services.Factories; | ||
using System.CommandLine.Parsing; | ||
|
||
namespace ExtSort.Models.Binders | ||
{ | ||
internal record GeneratorBinder | ||
{ | ||
public GeneratorBinder(ParseResult parser) | ||
{ | ||
var args = ArgumentFactory.GeneratorArguments.Value; | ||
|
||
if (!long.TryParse(parser.GetValueForArgument(args[nameof(TargetFileSizeKb)])?.ToString(), out var fileSizeKb)) | ||
throw new InvalidCastException("The length of the output file is in incorrect format."); | ||
|
||
TargetFileSizeKb = fileSizeKb; | ||
TargetFileName = (string)parser.GetValueForArgument(args[nameof(TargetFileName)]); | ||
} | ||
|
||
public string TargetFileName { get; init; } | ||
public long TargetFileSizeKb { get; init; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using ExtSort.Code.Enums; | ||
using ExtSort.Services.Factories; | ||
|
||
using System.CommandLine.Parsing; | ||
|
||
namespace ExtSort.Models.Binders | ||
{ | ||
internal record SorterBinder | ||
{ | ||
public SorterBinder(ParseResult parser) | ||
{ | ||
var args = ArgumentFactory.SorterArguments.Value; | ||
|
||
TargetFileName = (string)parser.GetValueForArgument(args[nameof(TargetFileName)]); | ||
SourceFileName = (string)parser.GetValueForArgument(args[nameof(SourceFileName)]); | ||
Mode = (SortMode)parser.GetValueForArgument(args[nameof(Mode)]); | ||
} | ||
|
||
public string TargetFileName { get; init; } | ||
public string SourceFileName { get; init; } | ||
public SortMode Mode { get; init; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using ExtSort.Models.Binders; | ||
|
||
using System.Text; | ||
|
||
namespace ExtSort.Models.Settings | ||
{ | ||
internal record EvaluatorSettings : EvaluatorBinder | ||
{ | ||
public EvaluatorSettings(EvaluatorBinder settings) : base(settings) | ||
{ | ||
|
||
} | ||
|
||
public bool Validate(out StringBuilder errors) | ||
{ | ||
errors = new StringBuilder(); | ||
if (NumberOfFiles < 1) | ||
errors.AppendLine("The number of files must be equal or greater than 1"); | ||
if (RamAvailableMb <= 0) | ||
errors.AppendLine("The RAM available must be greater than 0"); | ||
if (FileSizeMb <= 0) | ||
errors.AppendLine("The file size must be greater than 0"); | ||
if (DiskLatencyMs < 0) | ||
errors.AppendLine("The disk latency cannot be negative"); | ||
if (DiskRandomReadSpeedMbs <= 0) | ||
errors.AppendLine("The disk random access speed must be greather than 0"); | ||
|
||
return errors.Length == 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.