浏览代码

Corrected Binary Serialization of LoggablePropertyAttribute in CustomProperty class

Frank van den Bos 2 年之前
父节点
当前提交
cd7e444fc8
共有 1 个文件被更改,包括 11 次插入0 次删除
  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}");