2
0

libraryType in constructor

This commit is contained in:
glax 2023-06-03 16:24:14 +02:00
parent 783fd8129e
commit 2d82fe1489
3 changed files with 6 additions and 8 deletions

View File

@ -15,7 +15,7 @@ public abstract class LibraryManager
Kavita = 1
}
public LibraryType libraryType;
public LibraryType libraryType { get; }
public string baseUrl { get; }
protected string auth { get; } //Base64 encoded, if you use your password everywhere, you have problems
protected Logger? logger;
@ -23,11 +23,12 @@ public abstract class LibraryManager
/// <param name="baseUrl">Base-URL of Komga instance, no trailing slashes(/)</param>
/// <param name="auth">Base64 string of username and password (username):(password)</param>
/// <param name="logger"></param>
protected LibraryManager(string baseUrl, string auth, Logger? logger)
protected LibraryManager(string baseUrl, string auth, Logger? logger, LibraryType libraryType)
{
this.baseUrl = baseUrl;
this.auth = auth;
this.logger = logger;
this.libraryType = libraryType;
}
public abstract void UpdateLibrary();

View File

@ -6,9 +6,8 @@ namespace Tranga.LibraryManagers;
public class Kavita : LibraryManager
{
public Kavita(string baseUrl, string apiKey, Logger? logger) : base(baseUrl, apiKey, logger)
public Kavita(string baseUrl, string apiKey, Logger? logger) : base(baseUrl, apiKey, logger, LibraryType.Kavita)
{
this.libraryType = LibraryType.Kavita;
}
public override void UpdateLibrary()

View File

@ -12,15 +12,13 @@ namespace Tranga.LibraryManagers;
public class Komga : LibraryManager
{
public Komga(string baseUrl, string username, string password, Logger? logger)
: base(baseUrl, Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes($"{username}:{password}")), logger)
: base(baseUrl, Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes($"{username}:{password}")), logger, LibraryType.Komga)
{
this.libraryType = LibraryType.Komga;
}
[JsonConstructor]
public Komga(string baseUrl, string auth, Logger? logger) : base(baseUrl, auth, logger)
public Komga(string baseUrl, string auth, Logger? logger) : base(baseUrl, auth, logger, LibraryType.Komga)
{
this.libraryType = LibraryType.Komga;
}
public override void UpdateLibrary()