[성현모] 패키지설치, DI 패턴 적용.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,18 +7,15 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.Extensions.Logging">
|
|
||||||
<HintPath>..\DLL\Microsoft.Extensions.Logging.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
|
||||||
<HintPath>..\DLL\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Newtonsoft.Json">
|
|
||||||
<HintPath>..\DLL\Newtonsoft.Json.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="SystemX.Core">
|
<Reference Include="SystemX.Core">
|
||||||
<HintPath>..\DLL\SystemX.Core.dll</HintPath>
|
<HintPath>..\DLL\SystemX.Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="Config\LogXnetConfig.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,10 +1,17 @@
|
|||||||
|
using eCIAv2.WindowsApp.ViewModels;
|
||||||
|
|
||||||
namespace eCIAv2.WindowsApp
|
namespace eCIAv2.WindowsApp
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
public MainForm()
|
private readonly MainFromViewModel _vm;
|
||||||
|
|
||||||
|
public MainForm(MainFromViewModel vm)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_vm = vm;
|
||||||
|
|
||||||
|
var ss= _vm.LoadConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,21 @@
|
|||||||
|
using eCIAv2.WindowsApp.Services;
|
||||||
|
using eCIAv2.WindowsApp.ViewModels;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace eCIAv2.WindowsApp
|
namespace eCIAv2.WindowsApp
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
|
public static IHost AppHost { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
//LogXnet
|
||||||
string configDir = @$"{Application.StartupPath}Config";
|
string configDir = @$"{Application.StartupPath}Config";
|
||||||
//raed log4net configs
|
//raed log4net configs
|
||||||
if (LogXnet.ReadConfig(@$"{configDir}/LogXnetConfig.json") == true)
|
if (LogXnet.ReadConfig(@$"{configDir}/LogXnetConfig.json") == true)
|
||||||
@ -20,10 +28,23 @@ namespace eCIAv2.WindowsApp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
AppHost = Host.CreateDefaultBuilder()
|
||||||
// see https://aka.ms/applicationconfiguration.
|
.ConfigureServices((context, services) =>
|
||||||
|
{
|
||||||
|
// services
|
||||||
|
services.AddSingleton<ConfigService>();
|
||||||
|
|
||||||
|
//viewmodels
|
||||||
|
services.AddTransient<MainFromViewModel>();
|
||||||
|
|
||||||
|
// forms
|
||||||
|
services.AddTransient<MainForm>();
|
||||||
|
}).Build();
|
||||||
|
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new MainForm());
|
|
||||||
|
var form = AppHost.Services.GetRequiredService<MainForm>();
|
||||||
|
Application.Run(form);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
16
eCIAv2.WindowsApp/Services/ConfigService.cs
Normal file
16
eCIAv2.WindowsApp/Services/ConfigService.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace eCIAv2.WindowsApp.Services
|
||||||
|
{
|
||||||
|
public class ConfigService
|
||||||
|
{
|
||||||
|
public string LoadConfig()
|
||||||
|
{
|
||||||
|
return "loadConfig";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
eCIAv2.WindowsApp/ViewModels/MainFromViewModel.cs
Normal file
24
eCIAv2.WindowsApp/ViewModels/MainFromViewModel.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using eCIAv2.WindowsApp.Services;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace eCIAv2.WindowsApp.ViewModels
|
||||||
|
{
|
||||||
|
public class MainFromViewModel
|
||||||
|
{
|
||||||
|
private readonly ConfigService _configService;
|
||||||
|
|
||||||
|
public MainFromViewModel(ConfigService configService)
|
||||||
|
{
|
||||||
|
_configService = configService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string LoadConfig()
|
||||||
|
{
|
||||||
|
return _configService.LoadConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,29 +8,17 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\eCIAv2.Library\eCIAv2.Library.csproj" />
|
<ProjectReference Include="..\eCIAv2.Library\eCIAv2.Library.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.Extensions.DependencyInjection">
|
|
||||||
<HintPath>..\DLL\Microsoft.Extensions.DependencyInjection.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions">
|
|
||||||
<HintPath>..\DLL\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.Extensions.Logging">
|
|
||||||
<HintPath>..\DLL\Microsoft.Extensions.Logging.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
|
||||||
<HintPath>..\DLL\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.Extensions.Options">
|
|
||||||
<HintPath>..\DLL\Microsoft.Extensions.Options.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Newtonsoft.Json">
|
|
||||||
<HintPath>..\DLL\Newtonsoft.Json.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="SystemX.Core">
|
<Reference Include="SystemX.Core">
|
||||||
<HintPath>..\DLL\SystemX.Core.dll</HintPath>
|
<HintPath>..\DLL\SystemX.Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -42,4 +30,8 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Models\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user