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;
Console.WriteLine("Faut une ligne pour build");
Manager Mgr = new Manager(new Stub());
Mgr._persistance = new Persistance();
Mgr.SaveGames();

@ -4,20 +4,22 @@ using System.Xml;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.FileIO;
using Model;
using System.Runtime.InteropServices;
namespace StimPersistance
{
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)
{
XmlWriterSettings settings = new() { Indent = true };
DataContractSerializer serializer = new(typeof(ObservableCollection<Game>));
if (!File.Exists("games.xml")) File.Create("games.xml");
using (TextWriter tw = File.CreateText("games.xml"))
using (XmlWriter writer = XmlWriter.Create(tw, settings)) serializer.WriteObject(writer, games);

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

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

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

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

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

Loading…
Cancel
Save