unsafe public void ReadWriteBoxedWithStringArrayWithOneElement() { var srcData = new ComponentWithStringArray() { StringArray = new string[] { "One" } }; // Write to stream var buffer = new UnsafeAppendBuffer(0, 16, Allocator.Persistent); var writer = new ManagedObjectBinaryWriter(&buffer); var boxedSrcData = (object)srcData; writer.WriteObject(boxedSrcData); var objectTable = writer.GetUnityObjects(); // Read from stream var readStream = buffer.AsReader(); var reader = new ManagedObjectBinaryReader(&readStream, objectTable); var boxedRead = reader.ReadObject(typeof(ComponentWithStringArray)); // Check same ComponentWithStringArray.AreEqual(srcData, (ComponentWithStringArray)boxedRead); buffer.Dispose(); }
unsafe public void ReadWriteBoxedWithStringArrayWithOneElement() { var srcData = new ComponentWithStringArray() { StringArray = new string[] { "One" } }; // Write to stream var buffer = new UnsafeAppendBuffer(0, 16, Allocator.Persistent); var writer = new PropertiesBinaryWriter(&buffer); var boxedSrcData = (object)srcData; BoxedProperties.WriteBoxedType(boxedSrcData, writer); var objectTable = writer.GetObjectTable(); // Read from stream var readStream = writer.Buffer.AsReader(); var reader = new PropertiesBinaryReader(&readStream, objectTable); var boxedRead = BoxedProperties.ReadBoxedClass(typeof(ComponentWithStringArray), reader); // Check same ComponentWithStringArray.AreEqual(srcData, (ComponentWithStringArray)boxedRead); buffer.Dispose(); }
public static void AreEqual(ComponentWithStringArray expected, ComponentWithStringArray value) { Assert.AreEqual(expected.StringArray.Length, value.StringArray.Length); for (int i = 0; i < expected.StringArray.Length; ++i) { Assert.AreEqual(expected.StringArray[i], value.StringArray[i]); } }