public SaveableUSCurrencyRepo LoadRepo(string filePath) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(filePath, FileMode.Open); List <ICoin> coins = (List <ICoin>)formatter.Deserialize(stream); SaveableUSCurrencyRepo repo = new SaveableUSCurrencyRepo(); repo.Coins = coins; return(repo); }
private void SaveRepo() { if (string.IsNullOrEmpty(FilePath)) { SaveAsRepo(); } else { SaveableUSCurrencyRepo repo = new SaveableUSCurrencyRepo(repository); repo.SaveRepo(FilePath); } }
private void SaveAsRepo() { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Repository Files(*.repo)|*.repo"; if (dialog.ShowDialog() == true) { FilePath = dialog.FileName; SaveableUSCurrencyRepo repo = new SaveableUSCurrencyRepo(repository); repo.SaveRepo(FilePath); } }
private void OpenRepo() { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Repository Files(*.repo)|*.repo"; if (dialog.ShowDialog() == true) { SaveableUSCurrencyRepo repo = new SaveableUSCurrencyRepo(); FilePath = dialog.FileName; repository = repo.LoadRepo(FilePath); RaisePropertyChangedEvent("TotalValue"); } }