Sfoglia il codice sorgente

Fixed Serialization WriteObject and ReadObject Calls

Frank van den Bos 2 anni fa
parent
commit
7309812f7b
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      InABox.Core/Serialization.cs

+ 2 - 2
InABox.Core/Serialization.cs

@@ -727,7 +727,7 @@ namespace InABox.Core
         public static void WriteObjects<TObject>(this CoreBinaryWriter writer, Type type, ICollection<TObject>? objects)
         public static void WriteObjects<TObject>(this CoreBinaryWriter writer, Type type, ICollection<TObject>? objects)
             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 nObjs = objects?.Count ?? 0;
             var nObjs = objects?.Count ?? 0;
@@ -769,7 +769,7 @@ namespace InABox.Core
         
         
         public static List<TObject> ReadObjects<TObject>(this CoreBinaryReader reader, Type type) where TObject : BaseObject
         public static List<TObject> ReadObjects<TObject>(this CoreBinaryReader reader, Type type) 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 objs = new List<TObject>();
             var objs = new List<TObject>();