Class1.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Threading.Tasks;
  5. using static WpfAppA.model.Globals;
  6. using System.Threading.Tasks;
  7. using System.Runtime.Serialization;
  8. namespace WpfAppA.model
  9. {
  10. [DataContract]
  11. public class Hero
  12. {
  13. [DataMember]
  14. public string name { get; set; }
  15. [DataMember]
  16. public int Age { get; set; }
  17. [DataMember]
  18. public string power { get; set; }
  19. [DataMember]
  20. public string race { get; set; }
  21. [DataMember]
  22. public string photo { get; set; }
  23. [DataMember(Name = "dateOfLastVaccination")]
  24. private string? stringDate { get; set; }
  25. [IgnoreDataMember]
  26. public DateTime? dateOfLastVaccination
  27. {
  28. get
  29. {
  30. return stringDate == null ? null : DateTime.Parse(stringDate);
  31. }
  32. set
  33. {
  34. stringDate = value.ToString();
  35. }
  36. }
  37. public Uri? ImageBitmap
  38. {
  39. get
  40. {
  41. var imageName = Environment.CurrentDirectory + "./img/" + (photo ?? "");
  42. return System.IO.File.Exists(imageName) ? new Uri(imageName) : null;
  43. }
  44. }
  45. }
  46. }