Skip to content
Snippets Groups Projects
Commit 2f4e0c2d authored by LENERTZ PIERRE's avatar LENERTZ PIERRE
Browse files

Merge branch 'master' into 'master'

Partie injected in Mainform

See merge request deleted_user_177013/t4-foc21!22
parents 884a6b39 5b125601
Branches
No related merge requests found
......@@ -8,6 +8,7 @@ using System.Windows.Forms;
using fichier1.Model;
using fichier1.Views;
using fichier1.Controllers;
using fichier1.Data;
namespace fichier1
{
......@@ -16,11 +17,11 @@ namespace fichier1
private Partie game;
private IGameController ctrl;
public MainForm()
public MainForm(Partie partie)
{
InitializeComponent();
this.game = new Partie();
this.game = partie;
this.ctrl = new GameController(this.game);
}
......
......@@ -15,10 +15,14 @@ namespace fichier1.Model
private List<IObserver<Partie>> observers;
public int nbMots;
public Partie(int nbMots, float complexite, BddContext context)
public Partie(BddContext context)
{
this.nbMots = nbMots;
this.context = context;
}
public void init(int nbMots, float complexite)
{
this.nbMots = nbMots;
this.observers = new List<IObserver<Partie>>();
}
......
using fichier1.Data;
using fichier1.Views;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
......@@ -10,6 +11,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using fichier1.Controllers;
using fichier1.Model;
namespace fichier1
{
......@@ -34,14 +36,18 @@ namespace fichier1
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//serviceCollection.AddSingleton<Form1>();
serviceCollection.AddScoped<MainForm>();
serviceCollection.AddScoped<Partie>();
serviceCollection.AddScoped<CorrectionMot>();
serviceCollection.AddScoped<ViewDecoupage>();
serviceCollection.AddScoped<ViewResultats>();
serviceCollection.AddScoped<IGameController, GameController>();
ServiceProvider = serviceCollection.BuildServiceProvider();
ServiceProvider.GetRequiredService<BddContext>().Database.EnsureCreated();
//var form1 = ServiceProvider.GetRequiredService<Form1>();
//Application.Run(form1);
var form1 = ServiceProvider.GetRequiredService<MainForm>();
Application.Run(form1);
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment