Class1.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. }