Baseline: WPF/Avalonia/Cli/Core + plans (BROWSER_FEATURES_PLAN v2, MOBILE_PLAN v1)
This commit is contained in:
commit
21b7c4d8bd
60 changed files with 6581 additions and 0 deletions
35
VideoDownloader.App/Core/ConfigStore.cs
Normal file
35
VideoDownloader.App/Core/ConfigStore.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System.Text.Json;
|
||||
using VideoDownloader.Core.Config;
|
||||
|
||||
namespace VideoDownloader.App.Core;
|
||||
|
||||
/// <summary>%AppData%/VideoDownloader/config.json 으로 설정 영속화</summary>
|
||||
public static class ConfigStore
|
||||
{
|
||||
private static string Dir => Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VideoDownloader");
|
||||
private static string FilePath => Path.Combine(Dir, "config.json");
|
||||
|
||||
private static readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
|
||||
|
||||
public static AppConfig Load()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(FilePath))
|
||||
return JsonSerializer.Deserialize<AppConfig>(File.ReadAllText(FilePath)) ?? new AppConfig();
|
||||
}
|
||||
catch { /* 손상 시 기본값 */ }
|
||||
return new AppConfig();
|
||||
}
|
||||
|
||||
public static void Save(AppConfig config)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Dir);
|
||||
File.WriteAllText(FilePath, JsonSerializer.Serialize(config, JsonOpts));
|
||||
}
|
||||
catch { /* 저장 실패는 무시 */ }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue