Exemplo n.º 1
0
        /// <summary>
        /// This function will take the inf and parse it into InfSection's.
        ///
        /// The sections can then be ordered to create an execution order.
        /// </summary>
        public void ParseIntoSections( )
        {
            String       InfLine;
            StreamReader InfReader = new StreamReader(InfPath);

            InfSection CurrentSection = null;

            while ((InfLine = InfReader.ReadLine()) != null)
            {
                InfLine = InfLine.Trim();

                if (InfLine.Length == 0)
                {
                    //Add the current section to the list of sections.
                    if (CurrentSection != null)
                    {
                        InfSections.Add(CurrentSection);
                        CurrentSection = null;
                    }

                    continue;
                }

                if (InfLine[0] == '[')
                {
                    //if there can be sections without whitespace between them
                    //the code above to add the current section to InfSections must be added
                    CurrentSection = new InfSection(InfLine.Substring(1, InfLine.IndexOf(']') - 1));
                }
                else if (InfLine[0] == ';')
                {
                    continue;
                }
                else
                {
                    CurrentSection.AddLine(InfLine);
                }
            }


            if (CurrentSection != null)
            {
                //there was no whitespace after the last section
                //add the section to the list
                InfSections.Add(CurrentSection);
            }

            InfReader.Close();
        }