Antmicro.Migrant.ObjectWriter.WriteArrayRowRecursive C# (CSharp) Method

WriteArrayRowRecursive() private method

private WriteArrayRowRecursive ( Array array, int currentDimension, Type elementFormalType, int position ) : void
array System.Array
currentDimension int
elementFormalType System.Type
position int
return void
        private void WriteArrayRowRecursive(Array array, int currentDimension, Type elementFormalType, int[] position)
        {
            var length = array.GetLength(currentDimension);
            for(var i = 0; i < length; i++)
            {
                if(currentDimension == array.Rank - 1)
                {
                    // the final row
                    WriteField(elementFormalType, array.GetValue(position));
                }
                else
                {
                    WriteArrayRowRecursive(array, currentDimension + 1, elementFormalType, position);
                }
                position[currentDimension]++;
                for(var j = currentDimension + 1; j < array.Rank; j++)
                {
                    position[j] = 0;
                }
            }
        }