diff --git a/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs b/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs index 0e5eea2c8..1e4bceadd 100644 --- a/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs +++ b/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs @@ -27,7 +27,17 @@ public class VaultController private VaultInfo _currentVaultInfo; private readonly List _discoveredItems = new(); private readonly List _vaultContainer = new(); - private ObservableCollection _vaults = new(); + private ObservableCollection _vault = new(); + + private ObservableCollection Vaults + { + get => _vault; + set + { + _vault = value; + OnVaultsChange?.Invoke(); + } + } public VaultController(TrackingController trackingController, MainWindowViewModel mainWindowViewModel) { @@ -94,11 +104,11 @@ private void ParseVault() return; } - var removableVaultInfo = _vaults.FirstOrDefault(x => x.Location == _currentVaultInfo.Location); + var removableVaultInfo = Vaults.FirstOrDefault(x => x.Location == _currentVaultInfo.Location); if (removableVaultInfo != null) { - _vaults.Remove(removableVaultInfo); + Vaults.Remove(removableVaultInfo); } var vault = new Vault() @@ -124,7 +134,7 @@ private void ParseVault() vault.VaultContainer.Add(vaultContainer); } - _vaults.Add(vault); + Vaults.Add(vault); OnVaultsChange?.Invoke(); } catch (Exception e) @@ -177,7 +187,7 @@ private void UpdateUi() Application.Current.Dispatcher.Invoke(() => { var unknownVaultSelection = new Vault() { Location = "UNKNOWN" }; - var list = _vaults.ToList(); + var list = Vaults.ToList(); list.Insert(0, unknownVaultSelection); _mainWindowViewModel.VaultBindings.Vaults = list; @@ -199,19 +209,19 @@ public void LoadFromFile() { var localFileString = File.ReadAllText(localFilePath, Encoding.UTF8); var vaults = JsonSerializer.Deserialize>(localFileString) ?? new List(); - _vaults = new ObservableCollection(vaults); + Vaults = new ObservableCollection(vaults); return; } catch (Exception e) { ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); Log.Error(MethodBase.GetCurrentMethod()?.DeclaringType, e); - _vaults = new ObservableCollection(); + Vaults = new ObservableCollection(); return; } } - _vaults = new ObservableCollection(); + Vaults = new ObservableCollection(); } public void SaveInFile() @@ -220,7 +230,7 @@ public void SaveInFile() try { - var fileString = JsonSerializer.Serialize(_vaults); + var fileString = JsonSerializer.Serialize(Vaults); File.WriteAllText(localFilePath, fileString, Encoding.UTF8); } catch (Exception e)