public void LoadAppSettings() { lock (locker) { try { if (File.Exists(configurationFile)) { var xml = File.ReadAllText(configurationFile); CurrentNotesAppSettings = (NotesAppSettings)Serializer.FromXml(xml, typeof(NotesAppSettings)); CurrentNotesAppSettings.AllNotes.ForEach(x => x.TrackChanges(true)); SetStageParents(); } else { LogProvider.Log.Info(CustomModulesNames.PlayerXRay, "Could not find existing configuration file. Load defaults."); } } catch (Exception ex) { LogProvider.Log.Error(CustomModulesNames.PlayerXRay, "Could not load existing configuration file. Load defaults.", ex); } if (CurrentNotesAppSettings == null || CurrentNotesAppSettings.StagesList == null || CurrentNotesAppSettings.StagesList.Count == 0) { InitializeDefaultNotes(); } } }
public void InitializeDefaultNotes() { try { var resourcesAssembly = typeof(PlayerXRayNoteService).Assembly; var resourceName = "DriveHUD.PlayerXRay.Resources.DefaultNotes.xml"; using (var stream = resourcesAssembly.GetManifestResourceStream(resourceName)) { var xmlSerializer = new XmlSerializer(typeof(NotesAppSettings)); CurrentNotesAppSettings = xmlSerializer.Deserialize(stream) as NotesAppSettings; CurrentNotesAppSettings.AllNotes.ForEach(x => x.TrackChanges(true)); SetStageParents(); } } catch (Exception e) { LogProvider.Log.Error(CustomModulesNames.PlayerXRay, "Could not initialize default notes. Empty notes will be created.", e); CurrentNotesAppSettings = new NotesAppSettings(); } SaveAppSettings(); }
public SettingsViewModel(NotesAppSettings notesAppSettings) { this.notesAppSettings = notesAppSettings; }