You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
943 B
42 lines
943 B
using CoreLibrary.Joueurs;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace CoreLibrary.Manager
|
|
{
|
|
public class Manager : IDisposable
|
|
{
|
|
private bool estDetruit;
|
|
|
|
private readonly IPersistanceManager persistance;
|
|
|
|
private readonly IEnumerable<Joueur> joueurs;
|
|
public IEnumerable<Joueur> Joueurs => joueurs;
|
|
|
|
public Manager(IPersistanceManager persistance)
|
|
{
|
|
this.persistance = persistance;
|
|
joueurs = this.persistance.Charger();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
protected virtual void Dispose(bool detruire)
|
|
{
|
|
if (estDetruit) return;
|
|
|
|
persistance.Enregistrer(joueurs);
|
|
|
|
estDetruit = true;
|
|
}
|
|
|
|
~Manager()
|
|
{
|
|
Dispose(false);
|
|
}
|
|
}
|
|
}
|