DFLayoutPINFieldProperties.cs 890 B

12345678910111213141516171819202122232425262728293031323334353637
  1. namespace InABox.Core
  2. {
  3. public class DFLayoutPINFieldProperties : DFLayoutFieldProperties<string>
  4. {
  5. public int Length { get; set; }
  6. public DFLayoutPINFieldProperties()
  7. {
  8. Length = 4;
  9. }
  10. public override string FormatValue(object value)
  11. {
  12. return value?.ToString() ?? "";
  13. }
  14. public override object? ParseValue(object value)
  15. {
  16. if (value is int)
  17. return value.ToString();
  18. if (value is string) return value;
  19. return null;
  20. }
  21. protected override void LoadProperties()
  22. {
  23. base.LoadProperties();
  24. Length = GetProperty("Length", 4);
  25. }
  26. protected override void SaveProperties()
  27. {
  28. base.SaveProperties();
  29. SetProperty("Length", Length);
  30. }
  31. }
  32. }