namespace ProximaAnalizer.Helpers; internal class DisplayDataHelper(IDictionary Left, IDictionary Right) { public HashSet Time { get; } = []; public Dictionary> DataLeft { get; } = []; public Dictionary> DataRight { get; } = []; public void CreateData(List main, List? sub) { while (sub is not null && main.Count != sub.Count!) { switch (main.Count > sub.Count) { case true: main.RemoveAt(main.Count - 1); break; case false: sub.RemoveAt(sub.Count - 1); break; } } this.ClearData(); foreach (var item in main) { if (item is not IDictionary data) continue; long ticks = (long)data["time"]; //ticks -= ticks % 10000000; DateTime time = new(ticks); Time.Add(time); foreach (string key in Left.Keys) { if (!data.TryGetValue(key, out object? value) || value is null) continue; if (!DataLeft.TryGetValue(key, out List? collections) || collections is null) { collections = []; DataLeft[key] = collections; } collections.Add(Convert.ToSingle(value)); } foreach (string key in Right.Keys) { if (!data.TryGetValue(key, out object? value) || value is null) continue; if (!DataRight.TryGetValue(key, out List? collections) || collections is null) { collections = []; DataRight[key] = collections; } collections.Add(Convert.ToSingle(value)); } } if (sub is null) return; foreach (var item in sub) { if (item is not IDictionary data) continue; foreach (string key in Left.Keys) { if (!data.TryGetValue(key, out object? value) || value is null) continue; if (!DataLeft.TryGetValue(key, out List? collections) || collections is null) { collections = []; DataLeft[key] = collections; } collections.Add(Convert.ToSingle(value)); } foreach (string key in Right.Keys) { if (!data.TryGetValue(key, out object? value) || value is null) continue; if (!DataRight.TryGetValue(key, out List? collections) || collections is null) { collections = []; DataRight[key] = collections; } collections.Add(Convert.ToSingle(value)); } } } public void ClearData() { this.Time.Clear(); this.DataLeft.Clear(); this.DataRight.Clear(); } }