encapsulation tags

master
Anthony RICHARD 2 years ago
parent 5bd0f12a15
commit 27aedcc580

@ -61,18 +61,18 @@ namespace Model
} }
private string cover = default!; private string cover = default!;
[DataMember] public ReadOnlyCollection<string> Tags
public ObservableCollection<string> Tags
{ {
get => tags; get => tags.AsReadOnly();
private set private set
{ {
if (value == null || value.Count > 3) tags = new ObservableCollection<string>(); if (value == null || value.Count > 3) tags = new List<string>();
else tags = value; else tags = value.ToList();
NotifyPropertyChanged(); NotifyPropertyChanged();
} }
} }
private ObservableCollection<string> tags; [DataMember]
private List<string> tags;
public ReadOnlyCollection<Review> Reviews => reviews.AsReadOnly(); public ReadOnlyCollection<Review> Reviews => reviews.AsReadOnly();
@ -100,8 +100,8 @@ namespace Model
if (string.IsNullOrWhiteSpace(description)) Description = "Pas de description"; if (string.IsNullOrWhiteSpace(description)) Description = "Pas de description";
else Description = description; else Description = description;
Year = year; Year = year;
if (c_tags is not null) tags = new ObservableCollection<string>(c_tags); if (c_tags is not null) tags = new List<string>(c_tags);
else tags = new ObservableCollection<string>(); else tags = new List<string>();
if (string.IsNullOrWhiteSpace(cover)) Cover = "no_cover.png"; if (string.IsNullOrWhiteSpace(cover)) Cover = "no_cover.png";
else Cover = cover; else Cover = cover;
if (string.IsNullOrWhiteSpace(c_lien)) Lien = "Pas de lien"; if (string.IsNullOrWhiteSpace(c_lien)) Lien = "Pas de lien";
@ -168,7 +168,7 @@ namespace Model
} }
public void TagChange(List<string> newtag) public void TagChange(List<string> newtag)
{ {
if (newtag != null && newtag.Count<=3) tags = new ObservableCollection<string>(newtag); if (newtag != null && newtag.Count<=3) tags = new List<string>(newtag);
} }
public void NameChange(string newname) public void NameChange(string newname)
{ {

Loading…
Cancel
Save