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;
}
}
}