DataMapper 개선, MQTTPipeLine 개발 중
This commit is contained in:
@@ -131,6 +131,65 @@ namespace UVC.Data
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 모든 아이템이 추가 된것으로 표시합니다.
|
||||
/// 전체 데이터가 갱신되었을 때 사용합니다.
|
||||
/// </summary>
|
||||
public void InitData()
|
||||
{
|
||||
addedList.Clear();
|
||||
addedList.AddRange(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 다른 DataObject와 현재 객체를 비교하여 다른 부분만 설정합니다.
|
||||
/// 변경된 키는 자동으로 추적됩니다.
|
||||
/// </summary>
|
||||
/// <param name="other">비교할 DataObject</param>
|
||||
public void UpdateDifferent(IDataObject other)
|
||||
{
|
||||
if (other == null) return;
|
||||
if (other is DataArray otherArray)
|
||||
{
|
||||
addedList.Clear();
|
||||
removedList.Clear();
|
||||
modifiedList.Clear();
|
||||
|
||||
// 현재 DataArray와 비교하여 변경된 항목을 추적
|
||||
for (int i = 0; i < Math.Max(this.Count, otherArray.Count); i++)
|
||||
{
|
||||
if (i < this.Count && i < otherArray.Count)
|
||||
{
|
||||
if (!this[i].ToString().Equals(otherArray[i].ToString()))
|
||||
{
|
||||
modifiedList.Add(this[i]);
|
||||
this[i].UpdateDifferent(otherArray[i]);
|
||||
}
|
||||
}
|
||||
else if (i < this.Count)
|
||||
{
|
||||
removedList.Add(this[i]);
|
||||
}
|
||||
else if (i < otherArray.Count)
|
||||
{
|
||||
addedList.Add(otherArray[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 업데이트 된 객체를 반환합니다.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IDataObject GetUpdatedObject()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 항목을 추가합니다.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user