Explorar o código

Corrected Binary Serialization of LoggablePropertyAttribute in CustomProperty class

Frank van den Bos %!s(int64=2) %!d(string=hai) anos
pai
achega
cd7e444fc8
Modificáronse 1 ficheiros con 11 adicións e 0 borrados
  1. 11 0
      InABox.Core/DataTable.cs

+ 11 - 0
InABox.Core/DataTable.cs

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