[성현모] eCIA 컨피그 동기화
This commit is contained in:
3
Projects/eCIA_v2/Config/eCIAConfig.json
Normal file
3
Projects/eCIA_v2/Config/eCIAConfig.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"ProjectName": "eCIA v2 by SystemX2"
|
||||
}
|
||||
@ -9,6 +9,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eCIA_v2.Shared", "eCIA_v2\e
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eCIA_v2.Web", "eCIA_v2\eCIA_v2.Web\eCIA_v2.Web.csproj", "{E1C6EEC0-19BF-433B-AF54-7A85034146A5}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{2A3A057F-5D22-31FD-628C-DF5EF75AEF1E}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Config\eCIAConfig.json = Config\eCIAConfig.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
@inherits LayoutComponentBase
|
||||
@using eCIA_v2.Shared.Services
|
||||
@inherits LayoutComponentBase
|
||||
@inject ConfigService _configService;
|
||||
|
||||
<RadzenLayout>
|
||||
<RadzenBody>
|
||||
<div>
|
||||
<RadzenText Text="ProjectName"></RadzenText>
|
||||
<RadzenText Text="@($"{_configService?.GetConfig()?.ProjectName}")"></RadzenText>
|
||||
</div>
|
||||
<div style="margin:0; padding:0;">
|
||||
@Body
|
||||
@ -16,3 +18,11 @@
|
||||
</RadzenFooter>
|
||||
</RadzenLayout>
|
||||
<RadzenComponents />
|
||||
|
||||
@code{
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
_configService?.ReadConfig();
|
||||
}
|
||||
}
|
||||
13
Projects/eCIA_v2/eCIA_v2/eCIA_v2.Shared/Models/eCIAConfig.cs
Normal file
13
Projects/eCIA_v2/eCIA_v2/eCIA_v2.Shared/Models/eCIAConfig.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace eCIA_v2.Shared.Models
|
||||
{
|
||||
public class eCIAConfig
|
||||
{
|
||||
public string ProjectName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
using eCIA_v2.Shared.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace eCIA_v2.Shared.Services
|
||||
{
|
||||
public class ConfigService
|
||||
{
|
||||
private eCIAConfig? config = new eCIAConfig();
|
||||
|
||||
public void ReadConfig()
|
||||
{
|
||||
string projectDir = Path.Combine(AppContext.BaseDirectory, @"..\..\..\");
|
||||
|
||||
//Web프로젝트와 Windows프로젝트간 1뎁스 차이가 있어서 체크후 없으면 경로변경
|
||||
if (Directory.Exists($"{projectDir}../../Config") == false)
|
||||
projectDir = Path.Combine(projectDir, @"..\");
|
||||
|
||||
string sourceDir = $"{projectDir}../../Config/";
|
||||
string targetDir = $"{projectDir}/bin/Config/";
|
||||
|
||||
CopyDirectory(sourceDir, targetDir);
|
||||
|
||||
string readJson = File.ReadAllText($"{targetDir}/eCIAConfig.json");
|
||||
config = JsonConvert.DeserializeObject<eCIAConfig>(readJson);
|
||||
}
|
||||
|
||||
public static void CopyDirectory(string sourceDir, string targetDir, bool overwrite = true)
|
||||
{
|
||||
if (!Directory.Exists(sourceDir))
|
||||
{
|
||||
throw new DirectoryNotFoundException($"원본 디렉토리를 찾을 수 없습니다: {sourceDir}");
|
||||
}
|
||||
|
||||
// 대상 디렉토리 생성
|
||||
Directory.CreateDirectory(targetDir);
|
||||
|
||||
// 파일 복사
|
||||
foreach (string file in Directory.GetFiles(sourceDir))
|
||||
{
|
||||
string destFile = Path.Combine(targetDir, Path.GetFileName(file));
|
||||
File.Copy(file, destFile, overwrite);
|
||||
}
|
||||
|
||||
// 하위 디렉토리 재귀적으로 복사
|
||||
foreach (string subDir in Directory.GetDirectories(sourceDir))
|
||||
{
|
||||
string subDirName = Path.GetFileName(subDir);
|
||||
string destSubDir = Path.Combine(targetDir, subDirName);
|
||||
CopyDirectory(subDir, destSubDir, overwrite);
|
||||
}
|
||||
}
|
||||
|
||||
public eCIAConfig? GetConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
|
||||
@ -11,6 +11,7 @@ builder.Services.AddRazorComponents()
|
||||
|
||||
// Add device-specific services used by the eCIA_v2.Shared project
|
||||
builder.Services.AddSingleton<IFormFactor, FormFactor>();
|
||||
builder.Services.AddSingleton<ConfigService>();
|
||||
|
||||
builder.Services.AddRadzenComponents();
|
||||
|
||||
|
||||
@ -23,11 +23,12 @@ namespace eCIA_v2
|
||||
builder.Services.AddMauiBlazorWebView();
|
||||
builder.Services.AddRadzenComponents();
|
||||
|
||||
builder.Services.AddSingleton<ConfigService>();
|
||||
|
||||
#if DEBUG
|
||||
builder.Services.AddBlazorWebViewDeveloperTools();
|
||||
builder.Logging.AddDebug();
|
||||
#endif
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,10 @@
|
||||
"Windows Machine": {
|
||||
"commandName": "Project",
|
||||
"nativeDebugging": false
|
||||
},
|
||||
"WSL": {
|
||||
"commandName": "WSL2",
|
||||
"distributionName": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -37,6 +37,7 @@
|
||||
|
||||
<!-- 명시적으로 en-US만 포함 -->
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<RunPostBuildEvent>Always</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net9.0-windows10.0.19041.0|AnyCPU'">
|
||||
|
||||
Reference in New Issue
Block a user