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.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Runtime.CompilerServices;
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;
public string Nom => nom;
public string Description { get; set; }
public string Pouvoir { get; set;}
public string Strategies { get; set; }
public string Description {
get => description;
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;
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.");
}
note = value;
OnPropertyChanged(nameof(Note));
}
}
public string LienImage { get; set; } = "notFound";
public Carte(string nom, string pouvoir, string strategies, int? note, string lienImage, string description)
public string LienImage
{
get => lienImage;
set
{
if (!string.IsNullOrEmpty(lienImage)) lienImage = "notfound";
else lienImage = value;
OnPropertyChanged(nameof(LienImage));
}
}
private string lienImage;
public Carte(string nom, string pouvoir, string strategie, int? note, string lienImage, string description)
{
this.nom = nom;
Description = description;
Pouvoir = pouvoir;
Strategies = strategies;
Note = note;
LienImage = lienImage;
this.description = description;
this.pouvoir = pouvoir;
this.strategie = strategie;
this.note = note;
this.lienImage = LienImage;
}
}
}

Loading…
Cancel
Save