From 8a1e05aa0ae4a2602e048c4536ffd0fca37adb5a Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Thu, 30 Nov 2023 00:09:26 +0900 Subject: [PATCH 1/2] =?UTF-8?q?DumpUseCase=E3=81=AE=E6=94=B9=E4=BF=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...umpFileController.cs => DumpController.cs} | 14 ++-- .../Dump/DumpFileControllerFactory.cs | 6 +- .../Controllers/Dump/DumpFilePresenter.cs | 28 ------- .../Presenters/DumpPresenter.cs | 42 +++++++++++ .../.idea/workspace.xml | 75 +++++-------------- ...umpFileInteractor.cs => DumpInteractor.cs} | 27 ++++--- .../Runtime/UseCases/Commons/IInputData.cs | 14 ++++ .../Runtime/UseCases/Commons/IOutputData.cs | 18 +++++ .../KeySwitches/Dump/DumpFilePresenter.cs | 26 ------- .../KeySwitches/Dump/DumpFileRequest.cs | 5 -- .../KeySwitches/Dump/DumpOutputData.cs | 11 +++ ...umpFileResponse.cs => DumpOutputValuea.cs} | 6 +- .../KeySwitches/Dump/IDumpFileUseCase.cs | 13 ---- .../KeySwitches/Dump/IDumpPresenter.cs | 6 ++ .../UseCases/KeySwitches/Dump/IDumpUseCase.cs | 6 ++ 15 files changed, 142 insertions(+), 155 deletions(-) rename KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/{DumpFileController.cs => DumpController.cs} (72%) delete mode 100644 KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpFilePresenter.cs create mode 100644 KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Presenters/DumpPresenter.cs rename KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/{DumpFileInteractor.cs => DumpInteractor.cs} (56%) delete mode 100644 KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Dump/DumpFilePresenter.cs delete mode 100644 KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Dump/DumpFileRequest.cs create mode 100644 KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Dump/DumpOutputData.cs rename KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Dump/{DumpFileResponse.cs => DumpOutputValuea.cs} (66%) delete mode 100644 KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Dump/IDumpFileUseCase.cs create mode 100644 KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Dump/IDumpPresenter.cs create mode 100644 KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Dump/IDumpUseCase.cs diff --git a/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpFileController.cs b/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpController.cs similarity index 72% rename from KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpFileController.cs rename to KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpController.cs index 9e92f5ea..7ab97500 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpFileController.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpController.cs @@ -3,6 +3,7 @@ using KeySwitchManager.Domain.KeySwitches; using KeySwitchManager.Interactors.KeySwitches; +using KeySwitchManager.UseCase.Commons; using KeySwitchManager.UseCase.KeySwitches.Dump; using KeySwitchManager.UseCase.KeySwitches.Export; @@ -10,16 +11,16 @@ namespace KeySwitchManager.Applications.Standalone.Core.Controllers.Dump { - public class DumpFileController : IController + public class DumpController : IController { private IKeySwitchRepository SourceRepository { get; } private IExportStrategy Strategy { get; } - private IDumpFilePresenter Presenter { get; } + private IDumpPresenter Presenter { get; } - public DumpFileController( + public DumpController( IKeySwitchRepository sourceRepository, IExportStrategy strategy, - IDumpFilePresenter presenter ) + IDumpPresenter presenter ) { SourceRepository = sourceRepository; Strategy = strategy; @@ -33,14 +34,13 @@ public void Dispose() public async Task ExecuteAsync( CancellationToken cancellationToken ) { - IDumpFileUseCase interactor = new DumpFileInteractor( + IDumpUseCase interactor = new DumpInteractor( SourceRepository, Strategy, Presenter ); - var response = await interactor.ExecuteAsync( new DumpFileRequest(), cancellationToken ); - Presenter.Complete( response ); + await interactor.HandleAsync( UnitInputData.Default, cancellationToken ); } } } diff --git a/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpFileControllerFactory.cs b/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpFileControllerFactory.cs index 454f9af2..79cba951 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpFileControllerFactory.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpFileControllerFactory.cs @@ -1,10 +1,10 @@ using System.IO; using KeySwitchManager.Applications.Standalone.Core.Helpers; +using KeySwitchManager.Applications.Standalone.Core.Presenters; using KeySwitchManager.Applications.Standalone.Core.Views.LogView; using KeySwitchManager.Commons.Data; using KeySwitchManager.Infrastructures.Storage.Yaml.KeySwitches.Export; -using KeySwitchManager.UseCase.KeySwitches.Dump; using KeySwitchManager.UseCase.KeySwitches.Export; namespace KeySwitchManager.Applications.Standalone.Core.Controllers.Dump @@ -20,9 +20,9 @@ IController IDumpControllerFactory.Create( string databasePath, string outputFil var contentWriterFactory = new YamlExportContentFileWriterFactory( outputDirectory ); var strategy = new SingleExportStrategy( contentWriterFactory, contentFactory ); - var presenter = new IDumpFilePresenter.Console(); + var presenter = new DumpPresenter( logTextView ); - return new DumpFileController( + return new DumpController( database, strategy, presenter diff --git a/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpFilePresenter.cs b/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpFilePresenter.cs deleted file mode 100644 index 4fb1c394..00000000 --- a/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Dump/DumpFilePresenter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using KeySwitchManager.Applications.Standalone.Core.Views.LogView; -using KeySwitchManager.UseCase.KeySwitches.Dump; - -namespace KeySwitchManager.Applications.Standalone.Core.Controllers.Dump -{ - public class DumpFilePresenter : IDumpFilePresenter - { - private ILogTextView TextView { get; } - - public DumpFilePresenter( ILogTextView textView ) - { - TextView = textView; - } - - public void Present( T param ) - { - if( param != null ) - { - TextView.Append( param.ToString() ?? string.Empty ); - } - } - - public void Complete( DumpFileResponse response ) - { - TextView.Append( "Complete" ); - } - } -} diff --git a/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Presenters/DumpPresenter.cs b/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Presenters/DumpPresenter.cs new file mode 100644 index 00000000..4de89356 --- /dev/null +++ b/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Presenters/DumpPresenter.cs @@ -0,0 +1,42 @@ +using System.Threading; +using System.Threading.Tasks; + +using KeySwitchManager.Applications.Standalone.Core.Views.LogView; +using KeySwitchManager.UseCase.KeySwitches.Delete; +using KeySwitchManager.UseCase.KeySwitches.Dump; + +namespace KeySwitchManager.Applications.Standalone.Core.Presenters +{ + public sealed class DumpPresenter : IDumpPresenter + { + public static readonly IDeletePresenter Null = new NullImpl(); + + private ILogTextView TextView { get; } + + public DumpPresenter( ILogTextView textView ) + { + TextView = textView; + } + + public async Task HandleAsync( DumpOutputData outputData, CancellationToken cancellationToken = default ) + { + TextView.Append( $"{outputData.Value.DumpDataCount} record(s) dumped" ); + await Task.CompletedTask; + } + + #region NullObject + private class NullImpl : IDeletePresenter + { + public async Task HandleDeleteBeginAsync( DeleteInputData inputData, CancellationToken cancellationToken = default ) + { + await Task.CompletedTask; + } + + public async Task HandleAsync( DeleteOutputData outputData, CancellationToken cancellationToken = default ) + { + await Task.CompletedTask; + } + } + #endregion + } +} diff --git a/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/.idea/.idea.Applications.Xamarin.Mac/.idea/workspace.xml b/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/.idea/.idea.Applications.Xamarin.Mac/.idea/workspace.xml index ded27880..721b552f 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/.idea/.idea.Applications.Xamarin.Mac/.idea/workspace.xml +++ b/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/.idea/.idea.Applications.Xamarin.Mac/.idea/workspace.xml @@ -7,45 +7,7 @@