DataEntryUrlBox.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6. namespace MatrixIO.IO.Bmff.Boxes
  7. {
  8. /// <summary>
  9. /// Data Entry Url Box ("url ")
  10. /// </summary>
  11. [Box("url ", "Data Entry Url Box")]
  12. public class DataEntryUrlBox : FullBox
  13. {
  14. public DataEntryUrlBox() : base() { }
  15. public DataEntryUrlBox(Stream stream) : base(stream) { }
  16. internal override ulong CalculateSize()
  17. {
  18. return base.CalculateSize() + (String.IsNullOrEmpty(Location) ? 0 : (ulong)Encoding.UTF8.GetByteCount(Location));
  19. }
  20. protected override void LoadFromStream(Stream stream)
  21. {
  22. base.LoadFromStream(stream);
  23. Location = stream.ReadNullTerminatedUTF8String();
  24. }
  25. protected override void SaveToStream(Stream stream)
  26. {
  27. base.SaveToStream(stream);
  28. if(!String.IsNullOrEmpty(Location))
  29. stream.WriteUTF8String(Location);
  30. }
  31. public string Location { get; set; }
  32. }
  33. }