コード例 #1
0
ファイル: ArrayObject.cs プロジェクト: rogeralsing/Puzzle.NET
        public void Build(SerializerEngine engine, Array item)
        {
            int rank;

            int[] dimensions;
            int[] lowerBounds;
            int[] upperBounds;
            SetupLoopData(item, out rank, out dimensions, out lowerBounds, out upperBounds);
            int[] lengths = new int[rank];
            for (int i = 0; i < rank; i++)
            {
                lengths[i] = upperBounds[i] - lowerBounds[i] + 1;
            }

            Items = Array.CreateInstance(typeof(ObjectBase), lengths, lowerBounds);
            Array arr = Items;

            do
            {
                object     rawValue = item.GetValue(dimensions);
                ObjectBase obj      = engine.GetObject(rawValue);
                arr.SetValue(obj, dimensions);
            } while (IncreaseDimension(dimensions, lowerBounds, upperBounds, rank - 1));
        }
コード例 #2
0
 private void BuildSerilizationGraph(object graph)
 {
     Root = GetObject(graph);
 }
コード例 #3
0
 private void RegisterObject(ObjectBase current, object item)
 {
     objectLoookup.Add(item, current);
     current.Type = item.GetType();
     current.ID = GetObjectID();
     allObjects.Add(current);
 }
コード例 #4
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++;
                }
        }
コード例 #5
0
 private void BuildSerilizationGraph(object graph)
 {
     Root = GetObject(graph);
 }