mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-23 19:24:29 +08:00
refactor(SettingsSystem): 简化保存所有设置数据的逻辑
- 移除手动遍历设置数据的循环代码 - 使用 Repository.SaveAllAsync 方法批量保存所有数据 - 提高代码简洁性和执行效率
This commit is contained in:
parent
0c0ddaab7f
commit
ad6c621c59
@ -48,14 +48,7 @@ public class SettingsSystem<TRepository>(IDataRepository? repository)
|
||||
/// <returns>完成的任务</returns>
|
||||
public async Task SaveAll()
|
||||
{
|
||||
// 遍历所有设置数据并保存可持久化的数据
|
||||
foreach (var data in _model.AllData())
|
||||
{
|
||||
if (data is IData persistable)
|
||||
{
|
||||
await Repository.SaveAsync(persistable);
|
||||
}
|
||||
}
|
||||
await Repository.SaveAllAsync(_model.AllData());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user