Example #1
0
        private InfSection ReadUntilSection(string sectionName)
        {
            InfSection section = ReadNextSection();

            while (section != null)
            {
                _sections[section.Name] = section;
                if (section.Name.EqualsIgnoreCase(sectionName))
                {
                    return(section);
                }
                section = ReadNextSection();
            }

            return(new InfSection(sectionName));
        }
Example #2
0
        /// <summary>
        /// Reads the next section from the INF file.
        /// </summary>
        /// <returns>The next section from the INF file.</returns>
        private InfSection ReadNextSection()
        {
            InfSection section = null;
            string     line    = null;

            do
            {
                line = ReadLine();

                if (section != null)
                {
                    // We are inside a section.  Load the next line if it is not blank.
                    if (!string.IsNullOrEmpty(line))
                    {
                        section.Add(line);
                    }

                    // If the next line is a section line, then we are done with this section.
                    if (IsSectionLine(_nextLine))
                    {
                        return(section);
                    }
                }
                else
                {
                    // Check to see if the current line is a section.
                    if (IsSectionLine(line))
                    {
                        section = new InfSection(line);

                        // Corner case if a section is immediately followed by another section.
                        if (IsSectionLine(_nextLine))
                        {
                            return(section);
                        }
                    }
                }
            } while (line != null);

            // We have reached the end of the file.
            return(section);
        }