Allow injection of loggers

pull/32/head
Pat Hartl 2023-11-10 20:53:48 -06:00
parent 5237e88612
commit 20de9d6cae
3 changed files with 23 additions and 3 deletions

View File

@ -15,7 +15,7 @@ namespace LANCommander.SDK
{ {
public class Client public class Client
{ {
private static readonly ILogger Logger; private readonly ILogger Logger;
private readonly RestClient ApiClient; private readonly RestClient ApiClient;
private AuthToken Token; private AuthToken Token;
@ -26,6 +26,14 @@ namespace LANCommander.SDK
ApiClient = new RestClient(baseUrl); ApiClient = new RestClient(baseUrl);
} }
public Client(string baseUrl, ILogger logger)
{
if (!String.IsNullOrWhiteSpace(baseUrl))
ApiClient = new RestClient(baseUrl);
Logger = logger;
}
private T PostRequest<T>(string route, object body) private T PostRequest<T>(string route, object body)
{ {
var request = new RestRequest(route) var request = new RestRequest(route)

View File

@ -15,7 +15,7 @@ namespace LANCommander.SDK
{ {
public class GameManager public class GameManager
{ {
private static readonly ILogger Logger; private readonly ILogger Logger;
private Client Client { get; set; } private Client Client { get; set; }
private string DefaultInstallDirectory { get; set; } private string DefaultInstallDirectory { get; set; }
@ -30,6 +30,12 @@ namespace LANCommander.SDK
Client = client; Client = client;
} }
public GameManager(Client client, ILogger logger)
{
Client = client;
Logger = logger;
}
/// <summary> /// <summary>
/// Downloads, extracts, and runs post-install scripts for the specified game /// Downloads, extracts, and runs post-install scripts for the specified game
/// </summary> /// </summary>

View File

@ -15,7 +15,7 @@ namespace LANCommander.SDK
{ {
public class RedistributableManager public class RedistributableManager
{ {
private static readonly ILogger Logger; private readonly ILogger Logger;
private Client Client { get; set; } private Client Client { get; set; }
public delegate void OnArchiveEntryExtractionProgressHandler(object sender, ArchiveEntryExtractionProgressArgs e); public delegate void OnArchiveEntryExtractionProgressHandler(object sender, ArchiveEntryExtractionProgressArgs e);
@ -29,6 +29,12 @@ namespace LANCommander.SDK
Client = client; Client = client;
} }
public RedistributableManager(Client client, ILogger logger)
{
Client = client;
Logger = logger;
}
public void Install(Game game) public void Install(Game game)
{ {
foreach (var redistributable in game.Redistributables) foreach (var redistributable in game.Redistributables)