-
Notifications
You must be signed in to change notification settings - Fork 2
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 #72 from r-koubou/refactor/import_usecase
Refactor/import usecase
- Loading branch information
Showing
18 changed files
with
146 additions
and
123 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
28 changes: 0 additions & 28 deletions
28
...er/Sources/Runtime/Applications/Standalone.Core/Controllers/Import/ImportFilePresenter.cs
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
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
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
52 changes: 52 additions & 0 deletions
52
KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Presenters/ImportPresenter.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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
using KeySwitchManager.Applications.Standalone.Core.Views.LogView; | ||
using KeySwitchManager.Domain.KeySwitches.Models; | ||
using KeySwitchManager.UseCase.KeySwitches.Import; | ||
|
||
namespace KeySwitchManager.Applications.Standalone.Core.Presenters | ||
{ | ||
public class ImportPresenter : IImportFilePresenter | ||
{ | ||
public static readonly IImportFilePresenter Null = new NullImpl(); | ||
|
||
private ILogTextView TextView { get; } | ||
|
||
public ImportPresenter( ILogTextView textView ) | ||
{ | ||
TextView = textView; | ||
} | ||
|
||
public async Task HandleAsync( ImportOutputData outputData, CancellationToken cancellationToken = default ) | ||
{ | ||
var insertedCount = outputData.Value.InsertedCount; | ||
var updatedCount = outputData.Value.UpdatedCount; | ||
|
||
TextView.Append( $"{insertedCount} record(s) inserted, {updatedCount} record(s) updated" ); | ||
TextView.Append( "Complete" ); | ||
await Task.CompletedTask; | ||
} | ||
|
||
public async Task HandleImportedAsync( KeySwitch keySwitch, CancellationToken cancellationToken = default ) | ||
{ | ||
TextView.Append( $"{keySwitch}" ); | ||
await Task.CompletedTask; | ||
} | ||
|
||
#region NullObject | ||
private class NullImpl : IImportFilePresenter | ||
{ | ||
public async Task HandleAsync( ImportOutputData outputData, CancellationToken cancellationToken = default ) | ||
{ | ||
await Task.CompletedTask; | ||
} | ||
|
||
public async Task HandleImportedAsync( KeySwitch keySwitch, CancellationToken cancellationToken = default ) | ||
{ | ||
await Task.CompletedTask; | ||
} | ||
} | ||
#endregion | ||
} | ||
} |
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
17 changes: 0 additions & 17 deletions
17
KeySwitchManager/Sources/Runtime/UseCases/Commons/IPresenter.cs
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Import/IImportFileUseCase.cs
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Import/IImportUseCase.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using KeySwitchManager.UseCase.Commons; | ||
|
||
namespace KeySwitchManager.UseCase.KeySwitches.Import | ||
{ | ||
public interface IImportUseCase : IInputPort<ImportInputData> {} | ||
} |
28 changes: 9 additions & 19 deletions
28
KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Import/ImportFilePresenter.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,26 +1,16 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
using KeySwitchManager.Domain.KeySwitches.Models; | ||
using KeySwitchManager.UseCase.Commons; | ||
|
||
namespace KeySwitchManager.UseCase.KeySwitches.Import | ||
{ | ||
public interface IImportFilePresenter : IPresenter<ImportFileResponse> | ||
public interface IImportFilePresenter : IOutputPort<ImportOutputData> | ||
{ | ||
public class Null : IImportFilePresenter | ||
{ | ||
public void Complete( ImportFileResponse response ) | ||
{} | ||
} | ||
|
||
public class Console : IImportFilePresenter | ||
{ | ||
public void Present<T>( T param ) | ||
{ | ||
System.Console.WriteLine( param ); | ||
} | ||
void HandleImported( KeySwitch keySwitch ) | ||
=> HandleImportedAsync( keySwitch ).GetAwaiter().GetResult(); | ||
|
||
public void Message( string message ) | ||
{ | ||
System.Console.WriteLine( message ); | ||
} | ||
} | ||
Task HandleImportedAsync( KeySwitch keySwitch, CancellationToken cancellationToken = default ); | ||
} | ||
} | ||
} |
Oops, something went wrong.