Represents a page.
Ejemplo n.º 1
0
        /// <summary>
        /// Computes line number of a block in a page.
        /// </summary>
        /// <param name="block">The block to locate.</param>
        /// <param name="page">The page where the block is.</param>
        /// <returns>The block line.</returns>
        private int LocateBlockLine(Block block, Page page)
        {
            // Initialize the line to 1
            int line = 1;

            // Load the page until the block source position
            char[] buffer   = new char[block.SourcePosition];
            string pagePath = this.fileSystem.FileInfo.FromFileName(page.FileSystemPath).FullName;

            using (StreamReader reader = new StreamReader(this.fileSystem.File.Open(pagePath, FileMode.Open, FileAccess.Read, FileShare.Read)))
            {
                reader.Read(buffer, 0, buffer.Length);
            }

            // Count the number of line break to increment line number
            foreach (char currentChar in buffer)
            {
                if ('\n' == currentChar)
                {
                    ++line;
                }
            }

            // Return the line number
            return(line);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Computes line number of a block in a page.
        /// </summary>
        /// <param name="block">The block to locate.</param>
        /// <param name="page">The page where the block is.</param>
        /// <returns>The block line.</returns>
        private int LocateBlockLine(Block block, Page page)
        {
            // Initialize the line to 1
            int line = 1;

            // Load the page until the block source position
            char[] buffer = new char[block.SourcePosition];
            string pagePath = this.fileSystem.FileInfo.FromFileName(page.FileSystemPath).FullName;
            using (StreamReader reader = new StreamReader(this.fileSystem.File.Open(pagePath, FileMode.Open, FileAccess.Read, FileShare.Read)))
            {
                reader.Read(buffer, 0, buffer.Length);
            }

            // Count the number of line break to increment line number
            foreach (char currentChar in buffer)
            {
                if ('\n' == currentChar)
                {
                    ++line;
                }
            }

            // Return the line number
            return line;
        }