Browse Source

INABOX CORE - fix to serialization read and write singular items as well

Nick-PRSDigital@bitbucket.org 2 years ago
parent
commit
37cdeea363
1 changed files with 2 additions and 2 deletions
  1. 2 2
      InABox.Core/Serialization.cs

+ 2 - 2
InABox.Core/Serialization.cs

@@ -653,7 +653,7 @@ namespace InABox.Core
         public static void WriteObject<TObject>(this CoreBinaryWriter writer, TObject entity, Type type)
         public static void WriteObject<TObject>(this CoreBinaryWriter writer, TObject entity, Type type)
             where TObject : BaseObject
             where TObject : BaseObject
         {
         {
-            if (!type.IsAssignableFrom(typeof(TObject)))
+            if (!typeof(TObject).IsAssignableFrom(type))
                 throw new Exception($"{type.EntityName()} is not a subclass of {typeof(TObject).EntityName()}");
                 throw new Exception($"{type.EntityName()} is not a subclass of {typeof(TObject).EntityName()}");
 
 
             var properties = SerializableProperties(type).ToList();
             var properties = SerializableProperties(type).ToList();
@@ -682,7 +682,7 @@ namespace InABox.Core
         public static TObject ReadObject<TObject>(this CoreBinaryReader reader, Type type)
         public static TObject ReadObject<TObject>(this CoreBinaryReader reader, Type type)
             where TObject : BaseObject
             where TObject : BaseObject
         {
         {
-            if (!type.IsAssignableFrom(typeof(TObject)))
+            if (!typeof(TObject).IsAssignableFrom(type))
                 throw new Exception($"{type.EntityName()} is not a subclass of {typeof(TObject).EntityName()}");
                 throw new Exception($"{type.EntityName()} is not a subclass of {typeof(TObject).EntityName()}");
 
 
             var obj = (Activator.CreateInstance(type) as TObject)!;
             var obj = (Activator.CreateInstance(type) as TObject)!;