Modification OnPropertyCHanched avec CallerMemberName et ajout des onPrepertychanged
continuous-integration/drone/push Build is passing Details

pull/2/head
Loris OBRY 2 years ago
parent b1d7bd60a3
commit 7f1640b329

@ -4,16 +4,48 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Model namespace Model
{ {
public class Carte public class Carte : INotifyPropertyChanged
{ {
public event PropertyChangedEventHandler? PropertyChanged;
void OnPropertyChanged([CallerMemberName] string ?propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private readonly string nom; private readonly string nom;
public string Nom => nom; public string Nom => nom;
public string Description { get; set; } public string Description {
public string Pouvoir { get; set;} get => description;
public string Strategies { get; set; } set {
description = value;
OnPropertyChanged(nameof(Description));
}
}
private string description;
public string Pouvoir {
get => pouvoir;
set
{
pouvoir = value;
OnPropertyChanged(nameof(Pouvoir));
}
}
private string pouvoir;
public string Strategie
{
get => strategie;
set
{
strategie = value;
OnPropertyChanged(nameof(Strategie));
}
}
private string strategie;
private int? note; private int? note;
public int? Note public int? Note
{ {
@ -28,18 +60,28 @@ namespace Model
throw new ArgumentOutOfRangeException(nameof(value), "La valeur de la note doit être comprise entre 0 et 10."); throw new ArgumentOutOfRangeException(nameof(value), "La valeur de la note doit être comprise entre 0 et 10.");
} }
note = value; note = value;
OnPropertyChanged(nameof(Note));
}
}
public string LienImage
{
get => lienImage;
set
{
if (!string.IsNullOrEmpty(lienImage)) lienImage = "notfound";
else lienImage = value;
OnPropertyChanged(nameof(LienImage));
} }
} }
public string LienImage { get; set; } = "notFound"; private string lienImage;
public Carte(string nom, string pouvoir, string strategie, int? note, string lienImage, string description)
public Carte(string nom, string pouvoir, string strategies, int? note, string lienImage, string description)
{ {
this.nom = nom; this.nom = nom;
Description = description; this.description = description;
Pouvoir = pouvoir; this.pouvoir = pouvoir;
Strategies = strategies; this.strategie = strategie;
Note = note; this.note = note;
LienImage = lienImage; this.lienImage = LienImage;
} }
} }
} }

Loading…
Cancel
Save