58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using BestHTTP;
|
|
using EasyInject.Attributes;
|
|
using Newtonsoft.Json;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
/// <summary>
|
|
/// ºǫ́ϵͳ ÊôÐÔÉèÖÃÆ÷
|
|
/// </summary>
|
|
[Component]
|
|
public class BackendSystemSetting : ISetting
|
|
{
|
|
|
|
private NetWorkComponent netWork;
|
|
private Dictionary<string,object> _settingMap = new Dictionary<string, object>();
|
|
public string Code => "SYSTEM";
|
|
|
|
public bool inited = false;
|
|
|
|
|
|
|
|
public T Read<T>(string setItem)
|
|
{
|
|
object data = default;
|
|
if (_settingMap.TryGetValue(setItem,out data))
|
|
{
|
|
return (T)data;
|
|
}
|
|
return (T)data;
|
|
}
|
|
|
|
public bool Save<T>(string setItem, T value)
|
|
{
|
|
if(!_settingMap.ContainsKey(setItem))
|
|
{
|
|
_settingMap.Add(setItem, value);
|
|
netWork.RemoteSaveData(Code, JsonConvert.SerializeObject(_settingMap));
|
|
return true;
|
|
}
|
|
object data = default;
|
|
if(_settingMap.TryGetValue(setItem,out data))
|
|
{
|
|
data = value;
|
|
netWork.RemoteSaveData(Code, JsonConvert.SerializeObject(_settingMap));
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public void Remove(string setItem)
|
|
{
|
|
_settingMap.Remove(setItem);
|
|
netWork.RemoteSaveData(Code, JsonConvert.SerializeObject(_settingMap));
|
|
}
|
|
}
|