48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using LightSetupBase;
|
|
using System.Text.Json;
|
|
|
|
namespace LightSetupMd5
|
|
{
|
|
internal class Md5HttpExtend
|
|
{
|
|
public Dictionary<string, string> RequestAsync(Md5MainArgs arg, Md5Config config, Dictionary<string, string> defaultPara)
|
|
{
|
|
Dictionary<string, string> ret = new Dictionary<string, string>();
|
|
|
|
if (!arg.GetExtend)
|
|
{
|
|
WriteDefault(ret, defaultPara);
|
|
return ret;
|
|
}
|
|
|
|
string json = Md5HttpRequest.Request(config.GetHttpUrl, config.GetHttpFormat, defaultPara);
|
|
if (String.IsNullOrEmpty(json))
|
|
{
|
|
WriteDefault(ret, defaultPara);
|
|
return ret;
|
|
}
|
|
// 转换为合法的数据
|
|
Dictionary<string, object> res = JsonSerializer.Deserialize<Dictionary<string, object>>(json);
|
|
|
|
foreach (KeyValuePair<string, object> kvp in res)
|
|
{
|
|
if (kvp.Value == null)
|
|
{
|
|
continue;
|
|
}
|
|
ret.Add(kvp.Key, kvp.Value.ToString());
|
|
}
|
|
|
|
WriteDefault(ret, defaultPara);
|
|
return ret;
|
|
}
|
|
|
|
private void WriteDefault(Dictionary<string, string> ret, Dictionary<string, string> defaultPara)
|
|
{
|
|
foreach (KeyValuePair<string, string> kvp in defaultPara)
|
|
{
|
|
ret.Add(kvp.Key, kvp.Value.ToString());
|
|
}
|
|
}
|
|
}
|
|
} |