コード例 #1
0
        /// <summary>
        /// Creates a <see cref="Cell"/>.
        /// </summary>
        /// <param name="startColumnIndex">The index of the <see cref="Cell"/>'s start column.</param>
        /// <param name="endColumnIndex">The index of the <see cref="Cell"/>'s end column.</param>
        /// <param name="startRowIndex">The index of the <see cref="Cell"/>'s start row.</param>
        /// <param name="endRowIndex">The index of the <see cref="Cell"/>'s end row.</param>
        /// <param name="startOffset">The offset of the start of the <see cref="Cell"/> from the
        /// leftmost character of its containing table.</param>
        /// <param name="endOffset">The offset of the end of the <see cref="Cell"/> from the
        /// leftmost character of its containing table.</param>
        /// <param name="lineIndex">The index of the line within the <see cref="Cell"/>'s containing markdown document
        /// that the <see cref="Cell"/> begins at.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="startColumnIndex"/> is negative.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="endColumnIndex"/> is less than <paramref name="startColumnIndex"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="startRowIndex"/> is negative.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="endRowIndex"/> is less than <paramref name="startRowIndex"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="startOffset"/> is negative.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="endOffset"/> is not greater than <paramref name="startOffset"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="lineIndex"/> is negative.</exception>
        public Cell(int startColumnIndex,
                    int endColumnIndex,
                    int startRowIndex,
                    int endRowIndex,
                    int startOffset,
                    int endOffset,
                    int lineIndex)
        {
            if (startColumnIndex < 0)
            {
                throw new ArgumentOutOfRangeException(string.Format(Strings.ArgumentOutOfRangeException_Shared_ValueCannotBeNegative, startColumnIndex),
                                                      nameof(startColumnIndex));
            }

            if (endColumnIndex < startColumnIndex)
            {
                throw new ArgumentOutOfRangeException(string.Format(Strings.ArgumentOutOfRangeException_Shared_ValueMustNotBeLessThanOtherValue,
                                                                    endColumnIndex,
                                                                    nameof(startColumnIndex),
                                                                    startColumnIndex),
                                                      nameof(endColumnIndex));
            }

            if (startRowIndex < 0)
            {
                throw new ArgumentOutOfRangeException(string.Format(Strings.ArgumentOutOfRangeException_Shared_ValueCannotBeNegative, startRowIndex),
                                                      nameof(startRowIndex));
            }

            if (endRowIndex < startRowIndex)
            {
                throw new ArgumentOutOfRangeException(string.Format(Strings.ArgumentOutOfRangeException_Shared_ValueMustNotBeLessThanOtherValue,
                                                                    endRowIndex,
                                                                    nameof(startRowIndex),
                                                                    startRowIndex),
                                                      nameof(endRowIndex));
            }

            if (lineIndex < 0)
            {
                throw new ArgumentOutOfRangeException(string.Format(Strings.ArgumentOutOfRangeException_Shared_ValueCannotBeNegative, lineIndex),
                                                      nameof(lineIndex));
            }

            if (startOffset < 0)
            {
                throw new ArgumentOutOfRangeException(string.Format(Strings.ArgumentOutOfRangeException_Shared_ValueCannotBeNegative, startOffset),
                                                      nameof(startOffset));
            }

            if (endOffset <= startOffset)
            {
                throw new ArgumentOutOfRangeException(string.Format(Strings.ArgumentOutOfRangeException_Shared_ValueMustBeGreaterThanOtherValue,
                                                                    endOffset,
                                                                    nameof(startOffset),
                                                                    startOffset),
                                                      nameof(endOffset));
            }

            StartColumnIndex = startColumnIndex;
            EndColumnIndex   = endColumnIndex;
            StartRowIndex    = startRowIndex;
            EndRowIndex      = endRowIndex;
            StartOffset      = startOffset;
            EndOffset        = endOffset;
            LineIndex        = lineIndex;
            Lines            = new StringLineGroup(4);
            IsOpen           = true;
        }