|
|
|
@ -1,7 +1,11 @@
|
|
|
|
|
using Models;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using Models;
|
|
|
|
|
using Stub;
|
|
|
|
|
using DataContractPersistance;
|
|
|
|
|
using GameAtlas.Views;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using Microsoft.VisualBasic.FileIO;
|
|
|
|
|
using Models.API;
|
|
|
|
|
|
|
|
|
|
namespace GameAtlas;
|
|
|
|
|
|
|
|
|
@ -23,34 +27,42 @@ public partial class App : Application
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gestionnaire principal de l'application.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Manager MyManager { get; private set; } = new Manager(new Stub.Stub());//new Manager(new DataContractPersistance.DataContractPers());
|
|
|
|
|
public Manager MyManager { get; private set; }
|
|
|
|
|
|
|
|
|
|
private readonly IGDBClient _igdbClient;
|
|
|
|
|
private readonly IGDBSettings _igdbSettings;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructeur de l'application.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public App()
|
|
|
|
|
public App(IGDBClient igdbClient, IOptions<IGDBSettings> igdbSettings)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
MyManager = new Manager(new Stub.Stub(), _igdbClient);
|
|
|
|
|
|
|
|
|
|
if (File.Exists(Path.Combine(FilePath, FileName)))
|
|
|
|
|
{
|
|
|
|
|
//MyManager = new Manager(new DataContractPersistance.DataContractXML());
|
|
|
|
|
MyManager = new Manager(new DataContractPersistance.DataContractJSON());
|
|
|
|
|
}
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MyManager.ChargerDonnees();
|
|
|
|
|
|
|
|
|
|
MainPage = new AppShell();
|
|
|
|
|
|
|
|
|
|
_igdbClient = igdbClient;
|
|
|
|
|
_igdbSettings = igdbSettings.Value;
|
|
|
|
|
|
|
|
|
|
// For debug purposes, load games when the app starts
|
|
|
|
|
LoadGames();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!File.Exists(Path.Combine(FilePath, FileName)))
|
|
|
|
|
private async void LoadGames()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//MyManager.Persistance = new DataContractPersistance.DataContractXML();
|
|
|
|
|
MyManager.Persistance = new DataContractPersistance.DataContractJSON();
|
|
|
|
|
var games = await _igdbClient.GetGamesAsync();
|
|
|
|
|
Debug.WriteLine($"Games: {games}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MyManager.SauvegardeDonnees();
|
|
|
|
|
}
|
|
|
|
|
catch (HttpRequestException ex)
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine($"Request failed: {ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|