using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static WpfAppA.model.Globals; using System.Threading.Tasks; using System.Runtime.Serialization; namespace WpfAppA.model { [DataContract] public class Hero { [DataMember] public string name { get; set; } [DataMember] public int Age { get; set; } [DataMember] public string power { get; set; } [DataMember] public string race { get; set; } [DataMember] public string photo { get; set; } [DataMember(Name = "dateOfLastVaccination")] private string? stringDate { get; set; } [IgnoreDataMember] public DateTime? dateOfLastVaccination { get { return stringDate == null ? null : DateTime.Parse(stringDate); } set { stringDate = value.ToString(); } } public Uri? ImageBitmap { get { var imageName = Environment.CurrentDirectory + "./img/" + (photo ?? ""); return System.IO.File.Exists(imageName) ? new Uri(imageName) : null; } } } }