DFLayoutNotesFieldProperties.cs 972 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Newtonsoft.Json.Linq;
  2. using System;
  3. namespace InABox.Core
  4. {
  5. public class DFLayoutNotesFieldProperties : DFLayoutFieldProperties<string[], string[]?>
  6. {
  7. [EditorSequence(-995)]
  8. [NotesEditor]
  9. public override string[] Default { get; set; }
  10. public override string FormatValue(string[]? value)
  11. {
  12. if(value is string[] arr)
  13. {
  14. return string.Join(", ", arr);
  15. }
  16. else
  17. {
  18. return "";
  19. }
  20. }
  21. public override void SerializeValue(DFSaveStorageEntry entry, string[]? value)
  22. {
  23. entry.SetValue(value);
  24. }
  25. public override string[]? DeserializeValue(DFLoadStorageEntry entry)
  26. {
  27. return entry.GetValue<string[]>();
  28. }
  29. public override string[] GetValue(string[]? value)
  30. {
  31. return value ?? Default;
  32. }
  33. }
  34. }