[성현모] 패키지설치, DI 패턴 적용.

This commit is contained in:
SHM
2026-03-09 11:02:41 +09:00
parent 0b476f4072
commit 2c2c94f6fa
13 changed files with 88 additions and 31 deletions

View File

@ -1,79 +0,0 @@
{
"ConsoleEnable": true,
"FileOutputEnable": true,
"TimeStampEnable": true,
"ThreadIdEnable": true,
"AutoRemoveEnable": true,
"OutputFilePath": "/log",
"TimeStampForamt": "yyyy-MM-dd HH:mm:ss.fff",
"AutoRemoveIntervalDay": 10,
"LogLevel": "Debug",
"LogDefines": [
{
"LogLevel": "DEFAULT",
"LogLabel": "default",
"ForeColorRGB": "#fbebd2"
},
{
"LogLevel": "Debug",
"LogLabel": "Debug",
"ForeColorRGB": "#148CFF"
},
{
"LogLevel": "Debug",
"LogLabel": "Db",
"ForeColorRGB": "#46BEFF"
},
{
"LogLevel": "Debug",
"LogLabel": "HTTP",
"ForeColorRGB": "#6E6EFF"
},
{
"LogLevel": "Debug",
"LogLabel": "CONTROLLER",
"ForeColorRGB": "#B4B4FF"
},
{
"LogLevel": "Debug",
"LogLabel": "SOCKET",
"ForeColorRGB": "#5A78AF"
},
{
"LogLevel": "Information",
"LogLabel": "Information",
"ForeColorRGB": "22;198;12"
},
{
"LogLevel": "Information",
"LogLabel": "INFO",
"ForeColorRGB": "#419B4F"
},
{
"LogLevel": "Warning",
"LogLabel": "Warning",
"ForeColorRGB": "#E1B002"
},
{
"LogLevel": "Error",
"LogLabel": "Error",
"ForeColorRGB": "#ff0000"
},
{
"LogLevel": "Error",
"LogLabel": "Exception",
"ForeColorRGB": "255;123;123"
},
{
"LogLevel": "Critical",
"LogLabel": "Critical",
"ForeColorRGB": "#a70000"
},
{
"LogLevel": "Critical",
"LogLabel": "Fatal",
"ForeColorRGB": "#FF6347"
}
]
}

View File

@ -1,10 +1,17 @@
using eCIAv2.WindowsApp.ViewModels;
namespace eCIAv2.WindowsApp
{
public partial class MainForm : Form
{
public MainForm()
private readonly MainFromViewModel _vm;
public MainForm(MainFromViewModel vm)
{
InitializeComponent();
_vm = vm;
var ss= _vm.LoadConfig();
}
}
}

View File

@ -1,13 +1,21 @@
using eCIAv2.WindowsApp.Services;
using eCIAv2.WindowsApp.ViewModels;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace eCIAv2.WindowsApp
{
internal static class Program
{
public static IHost AppHost { get; private set; }
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
//LogXnet
string configDir = @$"{Application.StartupPath}Config";
//raed log4net configs
if (LogXnet.ReadConfig(@$"{configDir}/LogXnetConfig.json") == true)
@ -20,10 +28,23 @@ namespace eCIAv2.WindowsApp
return;
}
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
AppHost = Host.CreateDefaultBuilder()
.ConfigureServices((context, services) =>
{
// services
services.AddSingleton<ConfigService>();
//viewmodels
services.AddTransient<MainFromViewModel>();
// forms
services.AddTransient<MainForm>();
}).Build();
ApplicationConfiguration.Initialize();
Application.Run(new MainForm());
var form = AppHost.Services.GetRequiredService<MainForm>();
Application.Run(form);
}
}
}

View 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";
}
}
}

View 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();
}
}
}

View File

@ -8,29 +8,17 @@
<ImplicitUsings>enable</ImplicitUsings>
</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>
<ProjectReference Include="..\eCIAv2.Library\eCIAv2.Library.csproj" />
</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">
<HintPath>..\DLL\SystemX.Core.dll</HintPath>
</Reference>
@ -42,4 +30,8 @@
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>
</Project>