コード例 #1
0
        public void Deserialize_2D_ArrayObject()
        {
            int z = 0;

            ArrayObject arr = new ArrayObject();

            arr.ID   = 0;
            arr.Type = typeof(int[, ]);

            ObjectBase[,] items = new ObjectBase[4, 4];

            for (int x = 0; x < 4; x++)
            {
                for (int y = 0; y < 4; y++)
                {
                    items[x, y] = GetIntegerValueObject(z++);
                }
            }

            arr.Items = items;

            int[,] res = (int[, ])arr.GetValue();

            z = 0;
            for (int x = 0; x < 4; x++)
            {
                for (int y = 0; y < 4; y++)
                {
                    Assert.AreEqual(z, res[x, y]);
                    z++;
                }
            }
        }
コード例 #2
0
        public void Deserialize_Jagged_ArrayObject()
        {
            ArrayObject arr = new ArrayObject();

            arr.ID   = 0;
            arr.Type = typeof(int[][]);

            ArrayObject[] arrObjects = new ArrayObject[4];
            arrObjects[0] = GetIntegerArrayObject();
            arrObjects[1] = GetIntegerArrayObject();
            arrObjects[2] = GetIntegerArrayObject();
            arrObjects[3] = GetIntegerArrayObject();

            arr.Items = new ObjectBase[4] {
                arrObjects[0], arrObjects[1], arrObjects[2], arrObjects[3]
            };


            int[][] res = (int[][])arr.GetValue();

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    Assert.AreEqual(j, res[i][j]);
                }
            }
        }
コード例 #3
0
        public void Deserialize_1D_ArrayObject()
        {
            ArrayObject arr = GetIntegerArrayObject();

            int[] res = (int[])arr.GetValue();

            for (int i = 0; i < res.Length; i++)
            {
                Assert.AreEqual(i, res[i]);
            }
        }