diff --git a/src/Tagashi File Hub/App/Abstractions/AppBuilder.cs b/src/Tagashi File Hub/App/Abstractions/AppBuilder.cs new file mode 100644 index 0000000..8e45702 --- /dev/null +++ b/src/Tagashi File Hub/App/Abstractions/AppBuilder.cs @@ -0,0 +1,18 @@ +namespace Tagashi_File_Hub.App.Abstractions; + +internal class AppBuilder +{ + private List StartSteps { get; } = new(); + + public AppBuilder WithStartStep(IStartStep step) + { + StartSteps.Add(step); + + return this; + } + + public AppBuilder WithStartStep(Func step) + { + return WithStartStep(new DelegateStartStep(step)); + } +} \ No newline at end of file diff --git a/src/Tagashi File Hub/App/Abstractions/DelegateStartStep.cs b/src/Tagashi File Hub/App/Abstractions/DelegateStartStep.cs new file mode 100644 index 0000000..47fb4c4 --- /dev/null +++ b/src/Tagashi File Hub/App/Abstractions/DelegateStartStep.cs @@ -0,0 +1,16 @@ +namespace Tagashi_File_Hub.App.Abstractions; + +internal class DelegateStartStep : IStartStep +{ + private readonly Func _asyncDelegate; + + public DelegateStartStep(Func asyncDelegate) + { + _asyncDelegate = asyncDelegate; + } + + public async Task RunAsync() + { + await _asyncDelegate().ConfigureAwait(false); + } +} \ No newline at end of file diff --git a/src/Tagashi File Hub/App/Abstractions/IApp.cs b/src/Tagashi File Hub/App/Abstractions/IApp.cs new file mode 100644 index 0000000..e11b841 --- /dev/null +++ b/src/Tagashi File Hub/App/Abstractions/IApp.cs @@ -0,0 +1,5 @@ +namespace Tagashi_File_Hub.App.Abstractions; + +internal interface IApp +{ +} \ No newline at end of file diff --git a/src/Tagashi File Hub/App/Abstractions/IStartStep.cs b/src/Tagashi File Hub/App/Abstractions/IStartStep.cs new file mode 100644 index 0000000..6055f33 --- /dev/null +++ b/src/Tagashi File Hub/App/Abstractions/IStartStep.cs @@ -0,0 +1,6 @@ +namespace Tagashi_File_Hub.App.Abstractions; + +internal interface IStartStep +{ + public Task RunAsync(); +} \ No newline at end of file diff --git a/src/Tagashi File Hub/App/AppStarter.cs b/src/Tagashi File Hub/App/AppStarter.cs new file mode 100644 index 0000000..47497ba --- /dev/null +++ b/src/Tagashi File Hub/App/AppStarter.cs @@ -0,0 +1,5 @@ +namespace Tagashi_File_Hub.App; + +internal class AppStarter +{ +} \ No newline at end of file diff --git a/src/Tagashi File Hub/Form1.Designer.cs b/src/Tagashi File Hub/MainForm.Designer.cs similarity index 97% rename from src/Tagashi File Hub/Form1.Designer.cs rename to src/Tagashi File Hub/MainForm.Designer.cs index 3913125..697d1fc 100644 --- a/src/Tagashi File Hub/Form1.Designer.cs +++ b/src/Tagashi File Hub/MainForm.Designer.cs @@ -1,6 +1,6 @@ namespace Tagashi_File_Hub { - partial class Form1 + partial class MainForm { /// /// Required designer variable. @@ -28,7 +28,7 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); SuspendLayout(); // // Form1 diff --git a/src/Tagashi File Hub/Form1.cs b/src/Tagashi File Hub/MainForm.cs similarity index 55% rename from src/Tagashi File Hub/Form1.cs rename to src/Tagashi File Hub/MainForm.cs index 6c03ab6..f4aaf2f 100644 --- a/src/Tagashi File Hub/Form1.cs +++ b/src/Tagashi File Hub/MainForm.cs @@ -1,8 +1,8 @@ namespace Tagashi_File_Hub; -public partial class Form1 : Form +public partial class MainForm : Form { - public Form1() + public MainForm() { InitializeComponent(); } diff --git a/src/Tagashi File Hub/Form1.resx b/src/Tagashi File Hub/MainForm.resx similarity index 100% rename from src/Tagashi File Hub/Form1.resx rename to src/Tagashi File Hub/MainForm.resx diff --git a/src/Tagashi File Hub/Program.cs b/src/Tagashi File Hub/Program.cs index 4ecbd16..672c0f9 100644 --- a/src/Tagashi File Hub/Program.cs +++ b/src/Tagashi File Hub/Program.cs @@ -1,17 +1,31 @@ -namespace Tagashi_File_Hub +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Tagashi_File_Hub; + +internal static class Program { - internal static class Program + /// + /// The main entry point for the application. + /// + [STAThread] + private static void Main() { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + var hostBuilder = new HostBuilder().ConfigureServices((hostContext, services) => { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); - } + services.AddSingleton(); + }); + + using var host = hostBuilder.Build(); + var serviceProvider = host.Services; + var mainForm = serviceProvider.GetService(); + + Application.Run(mainForm); } } \ No newline at end of file diff --git a/src/Tagashi File Hub/Startup.cs b/src/Tagashi File Hub/Startup.cs new file mode 100644 index 0000000..222da36 --- /dev/null +++ b/src/Tagashi File Hub/Startup.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tagashi_File_Hub +{ + internal class Startup + { + } +} diff --git a/src/Tagashi File Hub/Tagashi File Hub.csproj b/src/Tagashi File Hub/Tagashi File Hub.csproj index b2411fe..4b220df 100644 --- a/src/Tagashi File Hub/Tagashi File Hub.csproj +++ b/src/Tagashi File Hub/Tagashi File Hub.csproj @@ -51,8 +51,16 @@ + + + + + + + + \ No newline at end of file