Ver Fonte

Corrected Binary Serialization of LoggablePropertyAttribute in CustomProperty class

Frank van den Bos há 2 anos atrás
pai
commit
cd7e444fc8
1 ficheiros alterados com 11 adições e 0 exclusões
  1. 11 0
      InABox.Core/DataTable.cs

+ 11 - 0
InABox.Core/DataTable.cs

@@ -805,6 +805,10 @@ namespace InABox.Core
             {
                 writer.Write(time.Ticks);
             }
+            else if (type == typeof(LoggablePropertyAttribute) && value is LoggablePropertyAttribute lpa)
+            {
+                writer.Write(lpa.Format ?? "");
+            }
             else
             {
                 throw new Exception($"Invalid type; Target DataType is {type} and value DataType is {value?.GetType().ToString() ?? "null"}");
@@ -907,6 +911,13 @@ namespace InABox.Core
             {
                 return new TimeSpan(reader.ReadInt64());
             }
+            else if (type == typeof(LoggablePropertyAttribute))
+            {
+                String format = reader.ReadString();
+                return String.IsNullOrWhiteSpace(format)
+                    ? null
+                    : new LoggablePropertyAttribute() { Format = format };
+            }
             else
             {
                 throw new Exception($"Invalid type; Target DataType is {type}");