DataMapper 개선, MQTTPipeLine 개발 중
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
#nullable enable
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UVC.Network;
|
||||
|
||||
@@ -34,18 +36,24 @@ namespace UVC.Data
|
||||
HttpPipeLineInfo info = infoList[key];
|
||||
|
||||
string result = await HttpRequester.Request<string>(info.url, info.method, info.body, info.headers);
|
||||
JObject jsonResult = JObject.Parse(result);
|
||||
DataObject dataObject = new DataObject(jsonResult);
|
||||
|
||||
if (info.dataMapper != null)
|
||||
IDataObject? dataObject = null;
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
dataObject = info.dataMapper.Map(jsonResult);
|
||||
}
|
||||
DataRepository.Instance.AddData(key, dataObject);
|
||||
if (info.handler != null)
|
||||
{
|
||||
info.handler(dataObject);
|
||||
result = result.Trim();
|
||||
if (result.StartsWith("{"))
|
||||
{
|
||||
JObject source = JObject.Parse(result);
|
||||
if (info.dataMapper != null) dataObject = info.dataMapper.Mapping(source);
|
||||
}
|
||||
else if(result.StartsWith("["))
|
||||
{
|
||||
JArray source = JArray.Parse(result);
|
||||
if (info.dataMapper != null) dataObject = info.dataMapper.Mapping(source);
|
||||
}
|
||||
}
|
||||
if(dataObject != null) dataObject = DataRepository.Instance.AddData(key, dataObject);
|
||||
info.handler?.Invoke(dataObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user