diff --git a/Sources/Console/Program.cs b/Sources/Console/Program.cs
index 9efc9f0..5a3382d 100644
--- a/Sources/Console/Program.cs
+++ b/Sources/Console/Program.cs
@@ -11,7 +11,6 @@ using System.Reflection.PortableExecutable;
// Déclaration des Managers (et de leur méthode de sauvegarde)
UserManager userMngr = new UserManager(new LoaderXml());
MonsterManager monsterBase = new MonsterManager(new LoaderStub());
-userMngr.addUser
// Variables statiques
bool isUserConnected = false;
diff --git a/Sources/Modèle/User.cs b/Sources/Modèle/User.cs
index 0f4ffb4..868b432 100644
--- a/Sources/Modèle/User.cs
+++ b/Sources/Modèle/User.cs
@@ -105,7 +105,7 @@ namespace Model
monstresDejaVu = monstresVus;
}
- /*
+
public User()
{
Pseudo = null;
@@ -114,7 +114,7 @@ namespace Model
Mdp = null;
monstresDejaVu = null;
}
- */
+
public bool verifyPssw(string pssw)
{
diff --git a/Sources/Persistance/LoaderXML.cs b/Sources/Persistance/LoaderXML.cs
index c8f39a6..f84c28e 100644
--- a/Sources/Persistance/LoaderXML.cs
+++ b/Sources/Persistance/LoaderXML.cs
@@ -14,23 +14,41 @@ using System.Dynamic;
using System.Xml.Linq;
namespace Persistance
-{
- public class LoaderXml : IUserDataManager, IMonsterDataManager
+{///
+/// Le problème vient du GetCurrentDirectory, le prof à dit que c'était le sujet du prochain cour donc je mets ça en pose.
+/// Chelou que ça marchait avant et je suis pas le seul à qui sa fait ça
+/// Avant il me mettait dans les fichiers du projet mais plus maintenant
+/// EN POSE
+///
+ public class LoaderXml : IUserDataManager, IMonsterDataManager
{
- static string path = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "../../"));
+ static string path = "/Saves/";
+ static string fichierUserXML = "users.xml";
+ static string fichierMonstreXML = "monsters.xml";
+
+ /*static string path = "/Saves/";
//static string path = Directory.GetCurrentDirectory() + "/../../";
static string fichierUserXML = "users.xml";
static string fichierMonstreXML = "monsters.xml";
-
-
+ */
+ bool exists = System.IO.Directory.Exists(Path.Combine(path, "/Saves/"));
+
// Serialisation / Deserialisation de Monstres
-
+ public void Chargement()
+ {
+ if (!exists)
+ {
+ Directory.CreateDirectory(path + "/Saves/");
+ }
+ }
+
void IMonsterDataManager.saveMonsters(List monstres)
{
- Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory())); // Setup le chemin d'accès
+ //Chargement();
+ Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), path)); // Setup le chemin d'accès
var serialiserXML = new DataContractSerializer(typeof(List));
XmlWriterSettings xmlSettings = new XmlWriterSettings() { Indent = true }; // Pour avoir le format xml dans le fichier ( indentation etc... )
- using (TextWriter tw = File.CreateText(Path.Combine(path, fichierMonstreXML)))
+ using (TextWriter tw = File.CreateText(Path.Combine(fichierMonstreXML)))
{
using (XmlWriter writer = XmlWriter.Create(tw, xmlSettings))
{
@@ -40,11 +58,13 @@ namespace Persistance
}
public List loadMonsters()
{
+ //Chargement();
+ Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), path));
var serialiserXML = new DataContractSerializer(typeof(List));
List? monsters;
try
{
- using (Stream s = File.OpenRead(Path.Combine(path, fichierMonstreXML)))
+ using (Stream s = File.OpenRead(fichierMonstreXML))
{
monsters = serialiserXML.ReadObject(s) as List;
}
@@ -56,11 +76,29 @@ namespace Persistance
return new List { };
}
// Serialisation / Deserialisation de Users
+ void IUserDataManager.saveUsers(List users)// Serialise correctement juste voir comment l'appelé en fonction de IUserDataManager
+ {
+ //Chargement();
+
+ Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), path)); // Setup le chemin d'accès
+ var serialiserXML = new DataContractSerializer(typeof(List));
+
+ XmlWriterSettings xmlSettings = new XmlWriterSettings() { Indent = true }; // Pour avoir le format xml dans le fichier ( indentation etc... )
+ using (TextWriter tw = File.CreateText(fichierUserXML))
+ {
+ using (XmlWriter writer = XmlWriter.Create(tw, xmlSettings))
+ {
+ serialiserXML.WriteObject(writer, users);
+ }
+ }
+ }
public List loadUsers()
{
+ Chargement();
+ Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), path));
var serialiserXML = new DataContractSerializer(typeof(List));
List? users;
- using (Stream s = File.OpenRead(Path.Combine(path, fichierUserXML)))
+ using (Stream s = File.OpenRead(fichierUserXML))
{
users = serialiserXML.ReadObject(s) as List;
}
@@ -70,24 +108,5 @@ namespace Persistance
}
return users;
}
-
- void IUserDataManager.saveUsers(List users)// Serialise correctement juste voir comment l'appelé en fonction de IUserDataManager
- {
- Directory.CreateDirectory("Saves");
- Directory.SetCurrentDirectory(path);
- var serialiserXML = new DataContractSerializer(typeof(List));
-
- XmlWriterSettings xmlSettings = new XmlWriterSettings() { Indent = true }; // Pour avoir le format xml dans le fichier ( indentation etc... )
- using (TextWriter tw = File.CreateText("users.xml"))
- {
- using (XmlWriter writer = XmlWriter.Create(tw, xmlSettings))
- {
- serialiserXML.WriteObject(writer, users);
- }
- }
- }
-
-
-
}
}
\ No newline at end of file
diff --git a/Sources/Vues/Inscription.xaml.cs b/Sources/Vues/Inscription.xaml.cs
index 62a35d9..831770f 100644
--- a/Sources/Vues/Inscription.xaml.cs
+++ b/Sources/Vues/Inscription.xaml.cs
@@ -6,8 +6,8 @@ public partial class Inscription : ContentPage
{
List users = new List();
UserManager userMngr = new UserManager(new LoaderXml());
- //public User user { get; set; } = new User();
- /*public Inscription()
+ public User user { get; set; } = new User();
+ public Inscription()
{
InitializeComponent();
BindingContext=user;
@@ -19,5 +19,5 @@ public partial class Inscription : ContentPage
userMngr.saveUsers(users);
}
- */
+
}
\ No newline at end of file