private void ReplaceConfig(Logs newConfig, string importPath)
        {
            var result = MessageBox.Show(
                $"Are you sure you want to replace your existing config file with {Path.GetFileName(importPath)}? This cannot be undone!",
                "Confirm Replace",
                MessageBoxButton.YesNo,
                MessageBoxImage.Warning);

            if (result == MessageBoxResult.No)
                MessageBox.Show("Import operation was aborted", "Aborted", MessageBoxButton.OK,
                    MessageBoxImage.Information);

            LogSource.Instance.ReplaceConfig(newConfig);
            LogSource.Instance.SaveState();
        }
Ejemplo n.º 2
0
 private void LoadLogs(string path)
 {
     using (var fs = File.OpenText(path))
     {
         var json = fs.ReadToEnd();
         Logs = JsonConvert.DeserializeObject<Logs>(json);
         OnLogSourceBound();
     }
 }
 private void MergeConfig(Logs newConfig)
 {
     // TODO: this badly needs some unit tests
     foreach (var group in newConfig.Groups)
     {
         if (!LogSource.Instance.Logs.Groups
             .Any(g => g.Name.Equals(group.Name, StringComparison.InvariantCultureIgnoreCase)))
         {
             // the group doesn't exist, so just add it
             // this should cover the logs in the group as well
             LogSource.Instance.AddGroup(group);
         }
         else
         {
             // if the group does exist add any new logs to it
             LogSource.Instance.AddLog(group, group.Logs);
         }
     }
 }
Ejemplo n.º 4
0
 public void ReplaceConfig(Logs logs)
 {
     Logs = logs;
     SaveState();
     OnLogSourceBound();
 }