mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
Merge pull request #92 from GeWuYou/deepsource-autofix-834b3193
refactor: use ternary operator for conditional assignments
This commit is contained in:
commit
248a29b4df
@ -46,12 +46,8 @@ public class DataRepository(IStorage? storage, DataRepositoryOptions? options =
|
|||||||
{
|
{
|
||||||
var key = location.ToStorageKey();
|
var key = location.ToStorageKey();
|
||||||
|
|
||||||
T result;
|
|
||||||
// 检查存储中是否存在指定键的数据
|
// 检查存储中是否存在指定键的数据
|
||||||
if (await Storage.ExistsAsync(key))
|
T result = await Storage.ExistsAsync(key) ? await Storage.ReadAsync<T>(key) : new T();
|
||||||
result = await Storage.ReadAsync<T>(key);
|
|
||||||
else
|
|
||||||
result = new T();
|
|
||||||
|
|
||||||
// 如果启用事件功能,则发送数据加载完成事件
|
// 如果启用事件功能,则发送数据加载完成事件
|
||||||
if (_options.EnableEvents)
|
if (_options.EnableEvents)
|
||||||
|
|||||||
@ -211,10 +211,7 @@ public class UnifiedSettingsDataRepository(
|
|||||||
|
|
||||||
var key = UnifiedKey;
|
var key = UnifiedKey;
|
||||||
|
|
||||||
if (await Storage.ExistsAsync(key))
|
_file = await Storage.ExistsAsync(key) ? await Storage.ReadAsync<UnifiedSettingsFile>(key) : new UnifiedSettingsFile { Version = 1 };
|
||||||
_file = await Storage.ReadAsync<UnifiedSettingsFile>(key);
|
|
||||||
else
|
|
||||||
_file = new UnifiedSettingsFile { Version = 1 };
|
|
||||||
|
|
||||||
_loaded = true;
|
_loaded = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user