|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Net.WebSockets;
|
|
|
using System.Reflection;
|
|
|
using System.Runtime.InteropServices.ComTypes;
|
|
|
using System.Threading;
|
|
@@ -225,7 +226,7 @@ namespace InABox.Core
|
|
|
{
|
|
|
public BinarySerializationSettings Settings { get; set; }
|
|
|
|
|
|
- public CoreBinaryReader(Stream stream, BinarySerializationSettings settings): base(stream)
|
|
|
+ public CoreBinaryReader(Stream stream, BinarySerializationSettings settings) : base(stream)
|
|
|
{
|
|
|
Settings = settings;
|
|
|
}
|
|
@@ -234,7 +235,7 @@ namespace InABox.Core
|
|
|
{
|
|
|
public BinarySerializationSettings Settings { get; set; }
|
|
|
|
|
|
- public CoreBinaryWriter(Stream stream, BinarySerializationSettings settings): base(stream)
|
|
|
+ public CoreBinaryWriter(Stream stream, BinarySerializationSettings settings) : base(stream)
|
|
|
{
|
|
|
Settings = settings;
|
|
|
}
|
|
@@ -422,7 +423,7 @@ namespace InABox.Core
|
|
|
}
|
|
|
else if (Nullable.GetUnderlyingType(type) is Type t)
|
|
|
{
|
|
|
- if(value == null)
|
|
|
+ if (value == null)
|
|
|
{
|
|
|
writer.Write(false);
|
|
|
}
|
|
@@ -432,6 +433,10 @@ namespace InABox.Core
|
|
|
writer.WriteBinaryValue(t, value);
|
|
|
}
|
|
|
}
|
|
|
+ else if (value is UserProperty userprop)
|
|
|
+ {
|
|
|
+ WriteBinaryValue(writer, userprop.Type, userprop.Value);
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
throw new Exception($"Invalid type; Target DataType is {type} and value DataType is {value?.GetType().ToString() ?? "null"}");
|
|
@@ -592,7 +597,7 @@ namespace InABox.Core
|
|
|
&& x.GetCustomAttribute<FormulaAttribute>() == null
|
|
|
&& x.GetCustomAttribute<ConditionAttribute>() == null
|
|
|
&& x.CanWrite);
|
|
|
- foreach(var prop in props)
|
|
|
+ foreach (var prop in props)
|
|
|
{
|
|
|
if (prop.PropertyType.GetInterfaces().Contains(typeof(IEnclosedEntity)))
|
|
|
{
|
|
@@ -638,7 +643,7 @@ namespace InABox.Core
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(prop.Parent.Getter()(obj) is BaseObject parent)
|
|
|
+ if (prop.Parent.Getter()(obj) is BaseObject parent)
|
|
|
{
|
|
|
parent.OriginalValues[prop.Name.Split('.').Last()] = value;
|
|
|
}
|
|
@@ -683,7 +688,7 @@ namespace InABox.Core
|
|
|
obj.SetObserving(false);
|
|
|
|
|
|
var nProps = reader.ReadInt32();
|
|
|
- for(int i = 0; i < nProps; ++i)
|
|
|
+ for (int i = 0; i < nProps; ++i)
|
|
|
{
|
|
|
var propName = reader.ReadString();
|
|
|
var property = DatabaseSchema.Property(typeof(TObject), propName);
|
|
@@ -742,18 +747,18 @@ namespace InABox.Core
|
|
|
|
|
|
var nObjs = reader.ReadInt32();
|
|
|
var nProps = reader.ReadInt32();
|
|
|
- for(int i = 0; i < nProps; ++i)
|
|
|
+ for (int i = 0; i < nProps; ++i)
|
|
|
{
|
|
|
var property = reader.ReadString();
|
|
|
properties.Add(DatabaseSchema.Property(typeof(TObject), property));
|
|
|
}
|
|
|
|
|
|
- for(int i = 0; i < nObjs; ++i)
|
|
|
+ for (int i = 0; i < nObjs; ++i)
|
|
|
{
|
|
|
var obj = new TObject();
|
|
|
obj.SetObserving(false);
|
|
|
|
|
|
- foreach(var property in properties)
|
|
|
+ foreach (var property in properties)
|
|
|
{
|
|
|
property?.Setter()(obj, reader.ReadBinaryValue(property.PropertyType));
|
|
|
}
|