DataMapper 개선, MQTTPipeLine 개발 중

This commit is contained in:
김형인
2025-06-06 02:17:54 +09:00
parent 4db2791486
commit d0e299585b
23 changed files with 524 additions and 141 deletions

View File

@@ -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);
}
}