diff --git a/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Create/CreateFileController.cs b/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Create/CreateFileController.cs index 53ef7103..b94a9472 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Create/CreateFileController.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Create/CreateFileController.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using KeySwitchManager.Interactors.KeySwitches; -using KeySwitchManager.UseCase.Commons; using KeySwitchManager.UseCase.KeySwitches.Create; using KeySwitchManager.UseCase.KeySwitches.Export; @@ -11,11 +10,11 @@ namespace KeySwitchManager.Applications.Standalone.Core.Controllers.Create public class CreateFileController : IController { private IExportStrategy Strategy { get; } - private IOutputPort Presenter { get; } + private ICreatePresenter Presenter { get; } public CreateFileController( IExportStrategy strategy, - IOutputPort presenter ) + ICreatePresenter presenter ) { Strategy = strategy; Presenter = presenter; diff --git a/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Create/CreateFileControllerFactory.cs b/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Create/CreateFileControllerFactory.cs index 78a394c7..531fda28 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Create/CreateFileControllerFactory.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Standalone.Core/Controllers/Create/CreateFileControllerFactory.cs @@ -5,7 +5,6 @@ using KeySwitchManager.Infrastructures.Storage.KeySwitches; using KeySwitchManager.Infrastructures.Storage.Spreadsheet.ClosedXml.KeySwitches.Export; using KeySwitchManager.Infrastructures.Storage.Yaml.KeySwitches.Export; -using KeySwitchManager.UseCase.Commons; using KeySwitchManager.UseCase.KeySwitches.Create; using KeySwitchManager.UseCase.KeySwitches.Export; @@ -13,12 +12,12 @@ namespace KeySwitchManager.Applications.Standalone.Core.Controllers.Create { public interface ICreateControllerFactory { - IController Create( string outputFilePath, IOutputPort presenter ); + IController Create( string outputFilePath, ICreatePresenter presenter ); } public class CreateFileControllerFactory : ICreateControllerFactory { - IController ICreateControllerFactory.Create( string outputFilePath, IOutputPort presenter ) + IController ICreateControllerFactory.Create( string outputFilePath, ICreatePresenter presenter ) { var outputDirectory = new DirectoryPath( Path.GetDirectoryName( outputFilePath ) ?? string.Empty ); var fileName = outputFilePath.ToLower(); 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 @@