|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
using Modèle;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
@ -9,10 +11,48 @@ namespace Persistance
|
|
|
|
|
{
|
|
|
|
|
public class DataContractPersistance : IPersistanceManager
|
|
|
|
|
{
|
|
|
|
|
public DataContractSerializer Serializer { get; set; }
|
|
|
|
|
= new DataContractSerializer(typeof(List<Requin>));
|
|
|
|
|
|
|
|
|
|
string FilePath { get; set; } = Path.Combine(Directory.GetCurrentDirectory(), "..//..//Persistance");
|
|
|
|
|
string FileName { get; set; }
|
|
|
|
|
|
|
|
|
|
string Filepers => Path.Combine(FilePath, FileName);
|
|
|
|
|
|
|
|
|
|
List<Requin> requins = new List<Requin>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Requin> LoadRequins()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
if (File.Exists(Filepers))
|
|
|
|
|
{
|
|
|
|
|
throw new FileNotFoundException("The persisance file Persisitance does not exist");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (Stream stream = File.OpenRead(Filepers))
|
|
|
|
|
{
|
|
|
|
|
requins = Serializer.ReadObject(stream) as List<Requin>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return requins;
|
|
|
|
|
}
|
|
|
|
|
public void SaveRequins(List<Requin> reqs)
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(FilePath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(FilePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (Stream stream = File.Create(Filepers))
|
|
|
|
|
{
|
|
|
|
|
Serializer.WriteObject(stream, requins);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Requin> LoadRequinsAdd()
|
|
|
|
|
{
|
|
|
|
@ -29,10 +69,6 @@ namespace Persistance
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveRequins(List<Requin> reqs)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveRequinsAdd(List<Requin> reqs)
|
|
|
|
|
{
|
|
|
|
|