コード例 #1
0
    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();
    }
コード例 #2
0
    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();
    }
コード例 #3
0
 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]);
     }
 }