-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Newtonsoft.Json; | ||
using SimpleFFmpegGUI.Model; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SimpleFFmpegGUI.Manager | ||
{ | ||
public static class ConfigManager | ||
{ | ||
public const string SyncModifiedTimeKey = "SyncModifiedTime"; | ||
|
||
public static bool SyncModifiedTime | ||
{ | ||
get => GetConfig(SyncModifiedTimeKey, true); | ||
set => SetConfig(SyncModifiedTimeKey, value); | ||
} | ||
|
||
public static T GetConfig<T>(string key, T defaultValue) | ||
{ | ||
using var db = FFmpegDbContext.GetNew(); | ||
var item = db.Configs.Where(p => p.Key == key).FirstOrDefault(); | ||
if (item == null) | ||
{ | ||
return defaultValue; | ||
} | ||
return Parse<T>(item.Value); | ||
} | ||
|
||
public static void SetConfig<T>(string key, T value) | ||
{ | ||
using var db = FFmpegDbContext.GetNew(); | ||
var item = db.Configs.Where(p => p.Key == key).FirstOrDefault(); | ||
if (item == null) | ||
{ | ||
item = new Config() | ||
{ | ||
Key = key, | ||
Value = GetString(value) | ||
}; | ||
db.Configs.Add(item); | ||
} | ||
else | ||
{ | ||
item.Value = GetString(value); | ||
db.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified; | ||
} | ||
|
||
db.SaveChanges(); | ||
} | ||
|
||
private static T Parse<T>(string data) | ||
{ | ||
return JsonConvert.DeserializeObject<T>(data); | ||
} | ||
|
||
private static string GetString<T>(T data) | ||
{ | ||
return JsonConvert.SerializeObject(data); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -633,4 +633,8 @@ | |
|
||
## 20230416 | ||
|
||
【WPF】优化在转码时的缩略图显示 | ||
【WPF】优化在转码时的缩略图显示 | ||
|
||
## 20230509 | ||
|
||
【Core】新增支持同步输出文件的修改文件为输入文件的修改时间(暂无设置UI) |