Esempio n. 1
0
        /// <summary>
        /// Gets the linenumber of this match in the original text.
        /// </summary>
        /// <param name="This">This Match.</param>
        /// <returns>The number of \n in the text before this match started.</returns>
        public static int LineNumber(this Match This)
        {
            Contract.Requires(This != null);
            if (!This.Success)
            {
                return(-1);
            }

            var text   = This.GetTextSource();
            var before = text.Substring(0, This.Index);
            var result = before.Count(c => c == '\n');

            return(result);
        }