System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteRectangle C# (CSharp) Method

WriteRectangle() private method

private WriteRectangle ( WriteObjectInfo objectInfo, int rank, int maxA, Array array, NameInfo arrayElemNameTypeInfo, int lowerBoundA ) : void
objectInfo WriteObjectInfo
rank int
maxA int
array System.Array
arrayElemNameTypeInfo NameInfo
lowerBoundA int
return void
        private void WriteRectangle(WriteObjectInfo objectInfo, int rank, int[] maxA, Array array, NameInfo arrayElemNameTypeInfo, int[] lowerBoundA)
        {
            int[] currentA = new int[rank];
            int[] indexMap = null;
            bool isLowerBound = false;
            if (lowerBoundA != null)
            {
                for (int i = 0; i < rank; i++)
                {
                    if (lowerBoundA[i] != 0)
                    {
                        isLowerBound = true;
                    }
                }
            }
            if (isLowerBound)
            {
                indexMap = new int[rank];
            }

            bool isLoop = true;
            while (isLoop)
            {
                isLoop = false;
                if (isLowerBound)
                {
                    for (int i = 0; i < rank; i++)
                    {
                        indexMap[i] = currentA[i] + lowerBoundA[i];
                    }

                    WriteArrayMember(objectInfo, arrayElemNameTypeInfo, array.GetValue(indexMap));
                }
                else
                {
                    WriteArrayMember(objectInfo, arrayElemNameTypeInfo, array.GetValue(currentA));
                }

                for (int irank = rank - 1; irank > -1; irank--)
                {
                    // Find the current or lower dimension which can be incremented.
                    if (currentA[irank] < maxA[irank] - 1)
                    {
                        // The current dimension is at maximum. Increase the next lower dimension by 1
                        currentA[irank]++;
                        if (irank < rank - 1)
                        {
                            // The current dimension and higher dimensions are zeroed.
                            for (int i = irank + 1; i < rank; i++)
                            {
                                currentA[i] = 0;
                            }
                        }
                        isLoop = true;
                        break;
                    }
                }
            }
        }