示例#1
0
            /// <summary>
            /// Verifies the given line number and index *only* against the Tokens listed in file (and not against the content)
            /// and initializes an instance of TokenIndex.
            /// Throws an ArgumentNullException if file is null.
            /// Throws an ArgumentOutOfRangeException if line or index are negative,
            /// or line is larger than or equal to the number of Tokens lists in file,
            /// or index is larger than or equal to the number of Tokens on the given line.
            /// </summary>
            internal TokenIndex(FileContentManager file, int line, int index)
            {
                this.File = file ?? throw new ArgumentNullException(nameof(file));
                if (line < 0 || line >= file.NrTokenizedLines())
                {
                    throw new ArgumentOutOfRangeException(nameof(line));
                }
                if (index < 0 || index >= file.GetTokenizedLine(line).Length)
                {
                    throw new ArgumentOutOfRangeException(nameof(index));
                }

                this.Line  = line;
                this.Index = index;
            }
示例#2
0
            /// <summary>
            /// Verifies the given line number and index *only* against the Tokens listed in file (and not against the
            /// content) and initializes an instance of TokenIndex.
            /// </summary>
            /// <exception cref="ArgumentOutOfRangeException">The line or index are negative.</exception>
            /// <exception cref="FileContentException">
            /// The line is outside the bounds of the file, or the index is outside the bounds of the line.
            /// </exception>
            internal TokenIndex(FileContentManager file, int line, int index)
            {
                if (line < 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(line));
                }
                if (index < 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(index));
                }
                if (line >= file.NrTokenizedLines())
                {
                    throw new FileContentException("Line exceeds the bounds of the file.");
                }
                if (index >= file.GetTokenizedLine(line).Length)
                {
                    throw new FileContentException("Token exceeds the bounds of the line.");
                }

                this.file  = file;
                this.Line  = line;
                this.Index = index;
            }