/// <summary> /// Method to invoke when the AddBackupSet command is executed. /// </summary> private void OnExcludeDirectoriesExecute() { //// Note that we use the type factory here because it will automatically take care of any dependencies //// that the BackupSetViewModel will add in the future var typeFactory = this.GetTypeFactory(); var excludedFilesViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <ExcludedDirectoriesViewModel>(BackupSet); if (_uiVisualizerService.ShowDialog(excludedFilesViewModel) ?? false) { ExcludedDirectories.Clear(); foreach (var ed in excludedFilesViewModel.GetExcludedDirectories(excludedFilesViewModel.Items[0]))//..ExcludedDirectories; { ExcludedDirectories.Add(ed.FullPath); } } }
/// <summary> /// Reads a text file encoded like below: /// 1:path /// 2:username /// 3:password /// 4:local-path /// 4: ... /// 4: local-path /// 5: excluded-path /// 5: ... /// </summary> /// <param name="file"></param> private void ReadSettings(String file) { BackupDirectories.Clear(); if (!File.Exists(file)) { return; } String line = String.Empty; using (StreamReader sr = new StreamReader(file)) { while ((line = sr.ReadLine()) != null && !String.IsNullOrEmpty(line.Trim())) { if (line.StartsWith("1:")) { TextBoxPath.Text = line.Substring(2); } else if (line.StartsWith("2:")) { TextBoxUsername.Text = line.Substring(2); } else if (line.StartsWith("3:")) { TextBoxPassword.Text = line.Substring(2); } else if (line.StartsWith("4:")) { BackupDirectories.Add(line.Substring(2)); } else if (line.StartsWith("5:")) { ExcludedDirectories.Add(line.Substring(2)); } else { throw new Exception(line); } } sr.Close(); } }