Skip to content

Commit

Permalink
Boundary・In/OutputDataまわりの整理
Browse files Browse the repository at this point in the history
  • Loading branch information
r-koubou committed Nov 28, 2023
1 parent 1a4ef4f commit b1c0ee3
Show file tree
Hide file tree
Showing 38 changed files with 215 additions and 248 deletions.
7 changes: 0 additions & 7 deletions KeySwitchManager/KeySwitchManager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Storage.Plist", "Sources\Ru
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Storage.Plist", "Sources\Tests\Infrastructures\Storage.Plist\Storage.Plist.csproj", "{33ED6810-D26B-419D-9A8E-C5F293E1431E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Boundaries", "Sources\Runtime\Boundaries\Boundaries.csproj", "{24F4F144-4C43-4B0D-A6E5-90A17B4140BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -156,10 +154,6 @@ Global
{33ED6810-D26B-419D-9A8E-C5F293E1431E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33ED6810-D26B-419D-9A8E-C5F293E1431E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33ED6810-D26B-419D-9A8E-C5F293E1431E}.Release|Any CPU.Build.0 = Release|Any CPU
{24F4F144-4C43-4B0D-A6E5-90A17B4140BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24F4F144-4C43-4B0D-A6E5-90A17B4140BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24F4F144-4C43-4B0D-A6E5-90A17B4140BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24F4F144-4C43-4B0D-A6E5-90A17B4140BC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{EAE5D07E-8455-4C33-BCD1-07EFF958E21B} = {505E86DD-3A59-4038-B109-22B3678D035E}
Expand Down Expand Up @@ -190,6 +184,5 @@ Global
{634AFB40-DAF4-4A06-8C2C-95880D514C28} = {929A1972-7C22-4700-A758-E99DF592BEBF}
{5F236D80-0102-44F7-904D-26A5A910C6C0} = {505E86DD-3A59-4038-B109-22B3678D035E}
{33ED6810-D26B-419D-9A8E-C5F293E1431E} = {B1FC3859-B078-471F-81F2-FBB0A25C974B}
{24F4F144-4C43-4B0D-A6E5-90A17B4140BC} = {4F7FDAC2-788F-437D-8498-7EA665B4B1CA}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@page "/create_db"

@inject FileDownloadService DownloadService
@using KeySwitchManager.Applications.Blazor.Services
@using KeySwitchManager.Applications.Standalone.Core.Controllers.Create
@using KeySwitchManager.Applications.Standalone.Core.Controllers.Export
@using KeySwitchManager.Applications.Standalone.Core.Views.LogView
@using KeySwitchManager.Applications.Blazor.Services
@using KeySwitchManager.Applications.Standalone.Core.Controllers.Create

@inject FileDownloadService DownloadService

<PageTitle>Create Database File</PageTitle>

Expand Down Expand Up @@ -43,7 +43,7 @@

var target = new MemoryStream();
var factory = new CreateToStreamControllerFactory();
var controller = factory.Create( target, Format, new ILogTextView.Null() );
var controller = factory.Create( target, Format, ILogTextView.Null );

var outputFileName = Format switch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@page "/fetchdata"
@inject HttpClient Http
@using KeySwitchManager.Applications.Blazor.Shared

<PageTitle>Weather forecast</PageTitle>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using KeySwitchManager.Applications.Blazor;
using KeySwitchManager.Applications.Blazor.Services;

using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

using MudBlazor.Services;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Automatically generated during the build and publish process
./VERSION.md
/VERSION.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using CommandLine;

using KeySwitchManager.Applications.Standalone.Core.Controllers.Create;
using KeySwitchManager.Applications.Standalone.Core.Presenters;
using KeySwitchManager.Applications.Standalone.Core.Views.LogView;
using KeySwitchManager.UseCase.KeySwitches.Create;

namespace KeySwitchManager.Applications.CLI.Commands
{
Expand All @@ -22,7 +22,7 @@ public int Execute( ICommandOption opt )

ICreateControllerFactory factory = new CreateFileControllerFactory();

using var controller = factory.Create( option.OutputPath, ICreatePresenter.DefaultConsole );
using var controller = factory.Create( option.OutputPath, new CreatePresenter( new ConsoleLogView() ) );
logView.Append( $"generating keyswitch template to {option.OutputPath}" );
controller.Execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;

using KeySwitchManager.Interactors.KeySwitches;
using KeySwitchManager.UseCase.Commons;
using KeySwitchManager.UseCase.KeySwitches.Create;
using KeySwitchManager.UseCase.KeySwitches.Export;

Expand All @@ -10,11 +11,11 @@ namespace KeySwitchManager.Applications.Standalone.Core.Controllers.Create
public class CreateFileController : IController
{
private IExportStrategy Strategy { get; }
private ICreatePresenter Presenter { get; }
private IOutputPort<CreateOutputData> Presenter { get; }

public CreateFileController(
IExportStrategy strategy,
ICreatePresenter presenter )
IOutputPort<CreateOutputData> presenter )
{
Strategy = strategy;
Presenter = presenter;
Expand All @@ -25,7 +26,7 @@ public void Dispose() {}
public async Task ExecuteAsync( CancellationToken cancellationToken )
{
ICreateUseCase interactor = new CreateInteractor( Presenter );
var request = new CreateRequest( Strategy );
var request = new CreateInputData( Strategy );
await interactor.HandleAsync( request, cancellationToken );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
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;

namespace KeySwitchManager.Applications.Standalone.Core.Controllers.Create
{
public interface ICreateControllerFactory
{
IController Create( string outputFilePath, ICreatePresenter logTextView );
IController Create( string outputFilePath, IOutputPort<CreateOutputData> presenter );
}

public class CreateFileControllerFactory : ICreateControllerFactory
{
IController ICreateControllerFactory.Create( string outputFilePath, ICreatePresenter logTextView )
IController ICreateControllerFactory.Create( string outputFilePath, IOutputPort<CreateOutputData> presenter )
{
var outputDirectory = new DirectoryPath( Path.GetDirectoryName( outputFilePath ) ?? string.Empty );
var fileName = outputFilePath.ToLower();
Expand All @@ -43,7 +44,7 @@ IController ICreateControllerFactory.Create( string outputFilePath, ICreatePrese
throw new ArgumentException( $"{outputFilePath} is unknown file format" );
}

return new CreateFileController( strategy, logTextView );
return new CreateFileController( strategy, presenter );
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using System.IO;

using KeySwitchManager.Applications.Standalone.Core.Controllers.Export;
using KeySwitchManager.Applications.Standalone.Core.Presenters;
using KeySwitchManager.Applications.Standalone.Core.Views.LogView;
using KeySwitchManager.Infrastructures.Storage.KeySwitches;
using KeySwitchManager.Infrastructures.Storage.Spreadsheet.ClosedXml.KeySwitches.Export;
using KeySwitchManager.Infrastructures.Storage.Yaml.KeySwitches.Export;
using KeySwitchManager.UseCase.KeySwitches.Create;
using KeySwitchManager.UseCase.KeySwitches.Export;

namespace KeySwitchManager.Applications.Standalone.Core.Controllers.Create
Expand All @@ -33,7 +33,7 @@ public IController Create( Stream targetStream, ExportSupportedFormat format, IL
throw new ArgumentOutOfRangeException( nameof( format ), format, null );
}

return new CreateFileController( strategy, ICreatePresenter.Null );
return new CreateFileController( strategy, CreatePresenter.Null );
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Threading;
using System.Threading.Tasks;

using KeySwitchManager.Applications.Standalone.Core.Views.LogView;
using KeySwitchManager.UseCase.Commons;
using KeySwitchManager.UseCase.KeySwitches.Create;

namespace KeySwitchManager.Applications.Standalone.Core.Presenters
{
public sealed class CreatePresenter : IOutputPort<CreateOutputData>
{
public static readonly IOutputPort<CreateOutputData> Null = new NullImpl();

private ILogTextView TextView { get; }

public CreatePresenter( ILogTextView textView )
{
TextView = textView;
}

public async Task HandleAsync( CreateOutputData outputData, CancellationToken cancellationToken = default )
{
if( outputData.Result )
{
TextView.Append( $"Created : {outputData.Value}" );
}
else
{
TextView.Append( "Failed to create." );

if( outputData.Error?.StackTrace != null )
{
TextView.Append( outputData.Error.StackTrace );
}
}

await Task.CompletedTask;
}

private class NullImpl : IOutputPort<CreateOutputData>
{
public async Task HandleAsync( CreateOutputData outputData, CancellationToken cancellationToken = default )
{
await Task.CompletedTask;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,25 @@ namespace KeySwitchManager.Applications.Standalone.Core.Views.LogView
{
public interface ILogTextView
{
public bool AutoScroll { get; set; }
static readonly ILogTextView Null = new NullImpl();

bool AutoScroll { get; set; }

void Append( string text );
void AppendError( string text );
void AppendError( Exception exception );
void Clear();
void ScrollToEnd();

public class Null : ILogTextView
private class NullImpl : ILogTextView
{
public bool AutoScroll { get; set; }

public void Append( string text )
{}

public void AppendError( string text )
{}

public void AppendError( Exception exception )
{}

public void Clear()
{}

public void ScrollToEnd()
{}
public void Append( string text ) {}
public void AppendError( string text ) {}
public void AppendError( Exception exception ) {}
public void Clear() {}
public void ScrollToEnd() {}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Automatically generated during the build and publish process
./VERSION.md
/VERSION.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Automatically generated during the build and publish process
./VERSION.md
/VERSION.md
Loading

0 comments on commit b1c0ee3

Please sign in to comment.