|
|
|
@ -0,0 +1,49 @@
|
|
|
|
|
using ParionsCuite.Modeles;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace ParionsCuite.DataContractPersistance
|
|
|
|
|
{
|
|
|
|
|
public class DataContractPersistance : IPersistanceManager
|
|
|
|
|
{
|
|
|
|
|
public string FilePath2 { get; set; } = Path.Combine(Directory.GetCurrentDirectory(), );
|
|
|
|
|
|
|
|
|
|
public string FilePath { get; set; } = "C:\\User" ;
|
|
|
|
|
|
|
|
|
|
public string FileName { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<Evenement> chargeDonnees()
|
|
|
|
|
{
|
|
|
|
|
var serializer = new DataContractSerializer(typeof(List<Evenement>));
|
|
|
|
|
List<Evenement> evenements;
|
|
|
|
|
|
|
|
|
|
using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName)))
|
|
|
|
|
{
|
|
|
|
|
evenements = serializer.ReadObject(s) as List<Evenement>;
|
|
|
|
|
}
|
|
|
|
|
return evenements;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void sauvegardeDonnees(List<Evenement> evenements)
|
|
|
|
|
{
|
|
|
|
|
var serialiser = new DataContractSerializer (typeof(List<Evenement>));
|
|
|
|
|
if (!Directory.Exists(FilePath))
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine("Directory créé à l'instant");
|
|
|
|
|
Debug.WriteLine(Directory.GetDirectoryRoot(FilePath));
|
|
|
|
|
Debug.WriteLine(FilePath + "\n");
|
|
|
|
|
Directory.CreateDirectory(FilePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (Stream s = File.Create(Path.Combine(FilePath, FileName)))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|