Exemple #1
0
        /// <param name="lines"></param>
        /// <param name="startIndex">Index of the first SETTING</param>
        /// <returns></returns>
        private int ProcessSettingsBlock(string[] lines, int startIndex, RMPropSetting setting)
        {
            int i = startIndex + 1; //move directly to the first OPTION or END

            for (; i < lines.Length && lines[i].Trim().ToUpper() != "END"; i++)
            {
                Console.WriteLine("ProcessSettingsBlock @ ln" + i);
                string   line      = lines[i].Trim();
                string[] lineParts = line.QASS(' ');

                //The only valid statement is OPTION.  The second parameter can be DEFAULT only.
                if (lineParts[0].ToUpper() != "OPTION")
                {
                    throw new Exception("Expected OPTION statement inside SETTING block @ line " + i);
                }
                else if (lineParts.Length < 2) //only OPTION on the line
                {
                    throw new Exception("Expected OPTION statement followed by either DEFAULT or [option's text] @ line " + i);
                }
                else
                {
                    if (lineParts[1] == "DEFAULT" && lineParts.Length == 3) //OPTION DEFAULT [text]
                    {
                        setting.AddOption(lineParts[2], true);
                    }
                    else
                    {
                        setting.AddOption(lineParts[1], false);
                    }
                }
            }
            return(i);
        }
        /// <param name="lines"></param>
        /// <param name="startIndex">Index of the first SETTING</param>
        /// <returns></returns>
        private int ProcessSettingsBlock(string[] lines, int startIndex, RMPropSetting setting)
        {
            int i = startIndex + 1; //move directly to the first OPTION or END
            for (; i < lines.Length && lines[i].Trim().ToUpper() != "END"; i++)
            {
                Console.WriteLine("ProcessSettingsBlock @ ln" + i);
                string line = lines[i].Trim();
                string[] lineParts = line.QASS(' ');

                //The only valid statement is OPTION.  The second parameter can be DEFAULT only.
                if (lineParts[0].ToUpper() != "OPTION")
                    throw new Exception("Expected OPTION statement inside SETTING block @ line " + i);
                else if(lineParts.Length < 2) //only OPTION on the line
                    throw new Exception("Expected OPTION statement followed by either DEFAULT or [option's text] @ line " + i);
                else
                {
                    if (lineParts[1] == "DEFAULT" && lineParts.Length == 3) //OPTION DEFAULT [text]
                        setting.AddOption(lineParts[2], true);
                    else
                        setting.AddOption(lineParts[1], false);
                }
            }
            return i;
        }