Derived Constructor

This commit is contained in:
glax 2023-06-15 17:06:41 +02:00
parent f280c01802
commit 088d1c4647

View File

@ -26,20 +26,24 @@ public class TaskManager
/// <param name="imageCachePath">Path to the cover-image cache</param> /// <param name="imageCachePath">Path to the cover-image cache</param>
/// <param name="libraryManagers"></param> /// <param name="libraryManagers"></param>
/// <param name="logger"></param> /// <param name="logger"></param>
public TaskManager(string downloadFolderPath, string workingDirectory, string imageCachePath, HashSet<LibraryManager> libraryManagers, Logger? logger = null) public TaskManager(string downloadFolderPath, string workingDirectory, string imageCachePath, HashSet<LibraryManager> libraryManagers, Logger? logger = null) : this(new TrangaSettings(downloadFolderPath, workingDirectory, libraryManagers), logger)
{
}
public TaskManager(TrangaSettings settings, Logger? logger = null)
{ {
this.logger = logger; this.logger = logger;
this.settings = new TrangaSettings(downloadFolderPath, workingDirectory, libraryManagers);
ExportDataAndSettings();
this._connectors = new Connector[] this._connectors = new Connector[]
{ {
new MangaDex(downloadFolderPath, imageCachePath, logger), new MangaDex(settings.downloadLocation, settings.coverImageCache, logger),
new Manganato(downloadFolderPath, imageCachePath, logger), new Manganato(settings.downloadLocation, settings.coverImageCache, logger),
new Mangasee(downloadFolderPath, imageCachePath, logger) new Mangasee(settings.downloadLocation, settings.coverImageCache, logger)
}; };
this.settings = settings;
ImportData();
ExportDataAndSettings();
Thread taskChecker = new(TaskCheckerThread); Thread taskChecker = new(TaskCheckerThread);
taskChecker.Start(); taskChecker.Start();
} }
@ -61,23 +65,6 @@ public class TaskManager
ExportDataAndSettings(); ExportDataAndSettings();
} }
public TaskManager(TrangaSettings settings, Logger? logger = null)
{
this.logger = logger;
this._connectors = new Connector[]
{
new MangaDex(settings.downloadLocation, settings.coverImageCache, logger),
new Manganato(settings.downloadLocation, settings.coverImageCache, logger),
new Mangasee(settings.downloadLocation, settings.coverImageCache, logger)
};
this.settings = settings;
ImportData();
ExportDataAndSettings();
Thread taskChecker = new(TaskCheckerThread);
taskChecker.Start();
}
/// <summary> /// <summary>
/// Runs continuously until shutdown. /// Runs continuously until shutdown.
/// Checks if tasks have to be executed (time elapsed) /// Checks if tasks have to be executed (time elapsed)