1
0

DescriptionLabel.cs 880 B

1234567891011121314151617181920212223242526272829303132
  1. using System.IO;
  2. using System.Text;
  3. using System.Xml;
  4. namespace AIPractice.Shared.Labels
  5. {
  6. public class DescriptionLabel: ImageLabel
  7. {
  8. public DescriptionLabel(string id, string title) : base(id, title)
  9. {
  10. }
  11. public static DescriptionLabel FromXml(string xmlContent)
  12. {
  13. using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(xmlContent)))
  14. {
  15. using (var r = XmlReader.Create(ms))
  16. {
  17. r.Read();
  18. var id = r.GetAttribute("id");
  19. var title = r.GetAttribute("title");
  20. return new DescriptionLabel(id, title);
  21. }
  22. }
  23. }
  24. public override string ToXml()
  25. {
  26. return $"<{nameof(DescriptionLabel)} id=\"{Id}\" title=\"{Title}\"/>";
  27. }
  28. }
  29. }