Ejemplo n.º 1
0
        public void DeserializeNestedTypes_FromSpan()
        {
            var tagStruct = (StructTestTag)BlamSerializer.Deserialize(typeof(StructTestTag), testTagData, 0, 100, null);

            AssertData(tagStruct);

            tagStruct = BlamSerializer.Deserialize <StructTestTag>(testTagData, 0, 100, null);
            AssertData(tagStruct);

            var tagRef = (ClassTestTag)BlamSerializer.Deserialize(typeof(ClassTestTag), testTagData, 0, 100, null);

            AssertData(tagRef);

            tagRef = BlamSerializer.Deserialize <ClassTestTag>(testTagData, 0, 100, null);
            AssertData(tagRef);


            var tagStructInstance = new StructTestTag();

            tagStructInstance = (StructTestTag)BlamSerializer.DeserializeInto(tagStructInstance, typeof(StructTestTag), testTagData, 0, 100, null);
            AssertData(tagStructInstance);

            tagStructInstance = new StructTestTag();
            tagStructInstance = BlamSerializer.DeserializeInto <StructTestTag>(tagStructInstance, testTagData, 0, 100, null);
            AssertData(tagStructInstance);

            var tagRefInstance = new ClassTestTag();

            tagRefInstance = (ClassTestTag)BlamSerializer.DeserializeInto(tagRefInstance, typeof(ClassTestTag), testTagData, 0, 100, null);
            AssertData(tagRefInstance);

            tagRefInstance = new ClassTestTag();
            tagRefInstance = BlamSerializer.DeserializeInto <ClassTestTag>(tagRefInstance, testTagData, 0, 100, null);
            AssertData(tagRefInstance);
        }
Ejemplo n.º 2
0
        private void AssertData(ClassTestTag tag)
        {
            Assert.IsNotNull(tag);

            Assert.AreEqual(119, tag.Value1);
            Assert.AreEqual(151.251f, tag.Value2, 3);

            Assert.AreEqual(2, tag.SubValues.Length);

            Assert.AreEqual(0.001f, tag.SubValues[1].SubSubTags[1].Value, 3);

            AssertData(tag.SubValues[0]);

            Assert.AreEqual(0xefbeadde, tag.SubValues[0].ArrayItem[0]);

            Assert.AreEqual("mt1", tag.SubValues[0].SubSubTags[0].StringVal);
        }
Ejemplo n.º 3
0
        public void DeserializeNestedTypes_FromStream()
        {
            var tagStruct = (StructTestTag)BlamSerializer.Deserialize(typeof(StructTestTag), new MemoryStream(testTagData), 0, 100, null);

            AssertData(tagStruct);

            tagStruct = BlamSerializer.Deserialize <StructTestTag>(new MemoryStream(testTagData), 0, 100, null);
            AssertData(tagStruct);

            var tagRef = (ClassTestTag)BlamSerializer.Deserialize(typeof(ClassTestTag), new MemoryStream(testTagData), 0, 100, null);

            AssertData(tagRef);

            tagRef = BlamSerializer.Deserialize <ClassTestTag>(new MemoryStream(testTagData), 0, 100, null);
            AssertData(tagRef);

            var offsetData = new byte[24 + testTagData.Length];

            testTagData.CopyTo(offsetData, 20);

            tagRef = BlamSerializer.Deserialize <ClassTestTag>(new MemoryStream(offsetData), 20, 80, null);
            AssertData(tagRef);

            var tagStructInstance = new StructTestTag();

            tagStructInstance = (StructTestTag)BlamSerializer.DeserializeInto(tagStructInstance, typeof(StructTestTag), new MemoryStream(testTagData), 0, 100, null);
            AssertData(tagStructInstance);

            tagStructInstance = new StructTestTag();
            tagStructInstance = BlamSerializer.DeserializeInto <StructTestTag>(tagStructInstance, new MemoryStream(testTagData), 0, 100, null);
            AssertData(tagStructInstance);

            var tagRefInstance = new ClassTestTag();

            tagRefInstance = (ClassTestTag)BlamSerializer.DeserializeInto(tagRefInstance, typeof(ClassTestTag), new MemoryStream(testTagData), 0, 100, null);
            AssertData(tagRefInstance);

            tagRefInstance = new ClassTestTag();
            tagRefInstance = BlamSerializer.DeserializeInto <ClassTestTag>(tagRefInstance, new MemoryStream(testTagData), 0, 100, null);
            AssertData(tagRefInstance);
        }