コード例 #1
0
        public void DeserializeComplex_ArrayComplexMultidimetional()
        {
            var value1 = new PublicConstructorWithParameters("value")
            {
                Prop1 = 1
            };
            var value2 = new PublicConstructorWithParameters("value")
            {
                Prop1 = 2
            };
            var value3 = new PublicConstructorWithParameters("value")
            {
                Prop1 = 3
            };
            var value4 = new PublicConstructorWithParameters("value")
            {
                Prop1 = 4
            };

            var array = new PublicConstructorWithParameters[2, 2] {
                { value1, value2 }, { value3, value4 }
            };
            var expressionStr = array.AsExpression().DefaultSerializer.Serialize();
            var deserializer  = new ComplexEntityExpressionDeserializer();
            var deserialized  = deserializer.Deserialize <PublicConstructorWithParameters[, ]>(expressionStr);

            Assert.Equal(1, deserialized[0, 0].Prop1);
            Assert.Equal(2, deserialized[0, 1].Prop1);
            Assert.Equal(3, deserialized[1, 0].Prop1);
            Assert.Equal(4, deserialized[1, 1].Prop1);
        }
コード例 #2
0
        public void DeserializeComplex_ArrayComplex()
        {
            var value1 = new PublicConstructorWithParameters("value")
            {
                Prop1 = 1
            };
            var value2 = new PublicConstructorWithParameters("value")
            {
                Prop1 = 2
            };
            var value3 = new PublicConstructorWithParameters("value")
            {
                Prop1 = 3
            };

            var array         = new PublicConstructorWithParameters[] { value1, value2, value3 };
            var expressionStr = array.AsExpression().DefaultSerializer.Serialize();
            var deserializer  = new ComplexEntityExpressionDeserializer();
            var deserialized  = deserializer.Deserialize <PublicConstructorWithParameters[]>(expressionStr);

            Assert.Equal(1, deserialized[0].Prop1);
            Assert.Equal(2, deserialized[1].Prop1);
            Assert.Equal(3, deserialized[2].Prop1);
        }