Feat : Chemin relatif j'crois ça marche wlh
continuous-integration/drone/push Build is passing Details

Popup_qui_marche_pas
Jade VAN BRABANDT 2 years ago
parent 6de8fcca19
commit 8109178795

@ -4,6 +4,3 @@ using StimStub;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
Console.WriteLine("Faut une ligne pour build"); Console.WriteLine("Faut une ligne pour build");
Manager Mgr = new Manager(new Stub());
Mgr._persistance = new Persistance();
Mgr.SaveGames();

@ -4,23 +4,25 @@ using System.Xml;
using Microsoft.VisualBasic; using Microsoft.VisualBasic;
using Microsoft.VisualBasic.FileIO; using Microsoft.VisualBasic.FileIO;
using Model; using Model;
using System.Runtime.InteropServices;
namespace StimPersistance namespace StimPersistance
{ {
public class Persistance : IPersistance public class Persistance : IPersistance
{ {
public Persistance() public Persistance(string chemin)
{ {
Directory.SetCurrentDirectory("C:\\Users\\axvanbraba\\source\\repos\\Projet_IHM\\Sources\\XML"); Directory.SetCurrentDirectory(chemin);
} }
public void SaveGame(ObservableCollection<Game> games) public void SaveGame(ObservableCollection<Game> games)
{ {
XmlWriterSettings settings = new() { Indent = true }; XmlWriterSettings settings = new() { Indent = true };
DataContractSerializer serializer = new(typeof(ObservableCollection<Game>)); DataContractSerializer serializer = new(typeof(ObservableCollection<Game>));
if (!File.Exists("games.xml")) File.Create("games.xml");
using (TextWriter tw = File.CreateText("games.xml")) using (TextWriter tw = File.CreateText("games.xml"))
using (XmlWriter writer = XmlWriter.Create(tw, settings)) serializer.WriteObject(writer, games); using (XmlWriter writer = XmlWriter.Create(tw, settings)) serializer.WriteObject(writer, games);
} }
public void SaveUser(List<User> users) public void SaveUser(List<User> users)

@ -89,7 +89,7 @@ namespace Model
{ {
Name = "Default"; Name = "Default";
Description = "Default"; Description = "Default";
Cover = "Default"; Cover = "Default.png";
Lien = "Default"; Lien = "Default";
Year = 2023; Year = 2023;
tags = new ObservableCollection<string>(); tags = new ObservableCollection<string>();

@ -1,11 +1,19 @@
namespace Stim; using Model;
using StimPersistance;
namespace Stim;
public partial class App : Application public partial class App : Application
{ {
Manager Mgr
{
get; set;
}
public App() public App()
{ {
InitializeComponent(); InitializeComponent();
string mainDir = FileSystem.Current.AppDataDirectory;
Mgr = new Manager(new Persistance(mainDir));
MainPage = new AppShell(); MainPage = new AppShell();
} }
} }

@ -2,10 +2,12 @@
using Model; using Model;
using StimPersistance; using StimPersistance;
using StimStub; using StimStub;
using Microsoft.Maui.Storage;
public partial class MainPage : ContentPage public partial class MainPage : ContentPage
{ {
public IPersistance persistance = new Persistance();
public IPersistance persistance = new Persistance(FileSystem.Current.AppDataDirectory);
public Manager Manager { get; set; } public Manager Manager { get; set; }
public MainPage() public MainPage()

@ -24,6 +24,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Persistance\Persistance.csproj" /> <ProjectReference Include="..\Persistance\Persistance.csproj" />
<ProjectReference Include="..\Stim.Model\Model.csproj" /> <ProjectReference Include="..\Stim.Model\Model.csproj" />
<ProjectReference Include="..\Stub\Stub.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1,5 +1,6 @@
using Model; using Model;
using StimPersistance; using StimPersistance;
using StimStub;
namespace Test namespace Test
{ {
@ -8,7 +9,7 @@ namespace Test
[Fact] [Fact]
public void Constructor() public void Constructor()
{ {
IPersistance persistance = new Persistance(); IPersistance persistance = new Stub();
Manager manager = new(persistance); Manager manager = new(persistance);
Assert.NotNull(manager); Assert.NotNull(manager);
} }
@ -16,7 +17,7 @@ namespace Test
[Fact] [Fact]
public void AddAndRemoveGame() public void AddAndRemoveGame()
{ {
IPersistance persistance = new Persistance(); IPersistance persistance = new Stub();
Manager manager = new(persistance); Manager manager = new(persistance);
Game game = new("game", "description", 2012, new List<String> { "1", "2", "3" }, "cover", "www.link.com"); Game game = new("game", "description", 2012, new List<String> { "1", "2", "3" }, "cover", "www.link.com");
manager.AddGametoGamesList(game); manager.AddGametoGamesList(game);

Loading…
Cancel
Save