namespace ProximaAnalizer.Helpers; internal class DBDisplayHelper(IDictionary Left, IDictionary Right) { public readonly HashSet Time = []; public readonly Dictionary> DataLeft = []; public readonly Dictionary> DataRight = []; public void CreateData(List main, List sub) { while (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; } } 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)); } } 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(); } }