-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from FizzcodeSoftware/dev
small fixes
- Loading branch information
Showing
6 changed files
with
88 additions
and
95 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
70 changes: 35 additions & 35 deletions
70
...ocalFiles/Processes/CreateDirectoryJob.cs → ...iles/Processes/CreateLocalDirectoryJob.cs
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 |
---|---|---|
@@ -1,36 +1,36 @@ | ||
namespace FizzCode.EtLast; | ||
|
||
public sealed class CreateDirectoryJob : AbstractJob | ||
{ | ||
[ProcessParameterMustHaveValue] | ||
public required string Path { get; init; } | ||
|
||
public override string GetTopic() => Path; | ||
|
||
protected override void ExecuteImpl(Stopwatch netTimeStopwatch) | ||
{ | ||
try | ||
{ | ||
if (!Directory.Exists(Path)) | ||
Directory.CreateDirectory(Path); | ||
} | ||
catch (Exception ex) | ||
{ | ||
var exception = new CreateDirectoryException(this, ex); | ||
exception.Data["Path"] = Path; | ||
throw exception; | ||
} | ||
} | ||
} | ||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public static class CreateDirectoryJobFluent | ||
{ | ||
public static IFlow CreateDirectory(this IFlow builder, string path) | ||
{ | ||
return builder.ExecuteProcess(() => new CreateDirectoryJob() | ||
{ | ||
Path = path, | ||
}); | ||
} | ||
namespace FizzCode.EtLast; | ||
|
||
public sealed class CreateLocalDirectoryJob : AbstractJob | ||
{ | ||
[ProcessParameterMustHaveValue] | ||
public required string Path { get; init; } | ||
|
||
public override string GetTopic() => Path; | ||
|
||
protected override void ExecuteImpl(Stopwatch netTimeStopwatch) | ||
{ | ||
try | ||
{ | ||
if (!Directory.Exists(Path)) | ||
Directory.CreateDirectory(Path); | ||
} | ||
catch (Exception ex) | ||
{ | ||
var exception = new CreateDirectoryException(this, ex); | ||
exception.Data["Path"] = Path; | ||
throw exception; | ||
} | ||
} | ||
} | ||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public static class CreateLocalDirectoryJobFluent | ||
{ | ||
public static IFlow CreateLocalDirectory(this IFlow builder, string path) | ||
{ | ||
return builder.ExecuteProcess(() => new CreateLocalDirectoryJob() | ||
{ | ||
Path = path, | ||
}); | ||
} | ||
} |
98 changes: 49 additions & 49 deletions
98
EtLast.LocalFiles/Processes/MoveFileJob.cs → ....LocalFiles/Processes/MoveLocalFileJob.cs
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 |
---|---|---|
@@ -1,50 +1,50 @@ | ||
namespace FizzCode.EtLast; | ||
|
||
public sealed class MoveFileJob : AbstractJob | ||
{ | ||
[ProcessParameterMustHaveValue] | ||
public required string SourceFileName { get; init; } | ||
|
||
[ProcessParameterMustHaveValue] | ||
public required string TargetFileName { get; init; } | ||
|
||
public required bool Overwrite { get; init; } | ||
|
||
public override string GetTopic() => SourceFileName; | ||
|
||
protected override void ExecuteImpl(Stopwatch netTimeStopwatch) | ||
{ | ||
try | ||
{ | ||
if (File.Exists(TargetFileName)) | ||
{ | ||
if (!Overwrite) | ||
return; | ||
} | ||
|
||
File.Move(SourceFileName, TargetFileName, true); | ||
} | ||
catch (Exception ex) | ||
{ | ||
var exception = new MoveFileException(this, ex); | ||
exception.Data["SourceFileName"] = SourceFileName; | ||
exception.Data["TargetFileName"] = TargetFileName; | ||
exception.Data["Overwrite"] = Overwrite; | ||
throw exception; | ||
} | ||
} | ||
} | ||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public static class MoveFileJobFluent | ||
{ | ||
public static IFlow MoveFile(this IFlow builder, string sourceFileName, string targetFileName, bool overwrite) | ||
{ | ||
return builder.ExecuteProcess(() => new MoveFileJob() | ||
{ | ||
SourceFileName = sourceFileName, | ||
TargetFileName = targetFileName, | ||
Overwrite = overwrite, | ||
}); | ||
} | ||
namespace FizzCode.EtLast; | ||
|
||
public sealed class MoveLocalFileJob : AbstractJob | ||
{ | ||
[ProcessParameterMustHaveValue] | ||
public required string SourceFileName { get; init; } | ||
|
||
[ProcessParameterMustHaveValue] | ||
public required string TargetFileName { get; init; } | ||
|
||
public required bool Overwrite { get; init; } | ||
|
||
public override string GetTopic() => SourceFileName; | ||
|
||
protected override void ExecuteImpl(Stopwatch netTimeStopwatch) | ||
{ | ||
try | ||
{ | ||
if (File.Exists(TargetFileName)) | ||
{ | ||
if (!Overwrite) | ||
return; | ||
} | ||
|
||
File.Move(SourceFileName, TargetFileName, true); | ||
} | ||
catch (Exception ex) | ||
{ | ||
var exception = new MoveFileException(this, ex); | ||
exception.Data["SourceFileName"] = SourceFileName; | ||
exception.Data["TargetFileName"] = TargetFileName; | ||
exception.Data["Overwrite"] = Overwrite; | ||
throw exception; | ||
} | ||
} | ||
} | ||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public static class MoveLocalFileJobFluent | ||
{ | ||
public static IFlow MoveLocalFile(this IFlow builder, string sourceFileName, string targetFileName, bool overwrite) | ||
{ | ||
return builder.ExecuteProcess(() => new MoveLocalFileJob() | ||
{ | ||
SourceFileName = sourceFileName, | ||
TargetFileName = targetFileName, | ||
Overwrite = overwrite, | ||
}); | ||
} | ||
} |
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 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