Converters

This commit is contained in:
glax 2023-07-31 01:48:40 +02:00
parent b3d778ff56
commit eb50b84266

View File

@ -28,7 +28,18 @@ public static class Migrator
MoveToCommonObjects(settingsFilePath, logger); MoveToCommonObjects(settingsFilePath, logger);
break; break;
} }
TrangaSettings.SettingsJsonObject sjo2 = JsonConvert.DeserializeObject<TrangaSettings.SettingsJsonObject>(File.ReadAllText(settingsFilePath))!;
TrangaSettings.SettingsJsonObject sjo2 = JsonConvert.DeserializeObject<TrangaSettings.SettingsJsonObject>(
File.ReadAllText(settingsFilePath),
new JsonSerializerSettings
{
Converters =
{
new TrangaTask.TrangaTaskJsonConverter(),
new NotificationManager.NotificationManagerJsonConverter(),
new LibraryManager.LibraryManagerJsonConverter()
}
})!;
sjo2.ts!.version = CurrentVersion; sjo2.ts!.version = CurrentVersion;
sjo2.ts!.ExportSettings(); sjo2.ts!.ExportSettings();
} }
@ -40,7 +51,8 @@ public static class Migrator
logger?.WriteLine("Migrator", "Removing old/deprecated UpdateLibraryTasks (v16)"); logger?.WriteLine("Migrator", "Removing old/deprecated UpdateLibraryTasks (v16)");
string tasksJsonString = File.ReadAllText(settings.tasksFilePath); string tasksJsonString = File.ReadAllText(settings.tasksFilePath);
HashSet<TrangaTask> tasks = JsonConvert.DeserializeObject<HashSet<TrangaTask>>(tasksJsonString, new JsonSerializerSettings { Converters = { new TrangaTask.TrangaTaskJsonConverter() } })!; HashSet<TrangaTask> tasks = JsonConvert.DeserializeObject<HashSet<TrangaTask>>(tasksJsonString,
new JsonSerializerSettings { Converters = { new TrangaTask.TrangaTaskJsonConverter() } })!;
tasks.RemoveWhere(t => t.task == TrangaTask.Task.UpdateLibraries); tasks.RemoveWhere(t => t.task == TrangaTask.Task.UpdateLibraries);
File.WriteAllText(settings.tasksFilePath, JsonConvert.SerializeObject(tasks)); File.WriteAllText(settings.tasksFilePath, JsonConvert.SerializeObject(tasks));
} }