Beispiel #1
0
 private void ExpectSectionName(char c)
 {
     if (c == '[')
     {
         ++NumberOfClosingBracketsExpected;
         Buffer.Append(c);
     }
     else if (c == ']')
     {
         if (0 == NumberOfClosingBracketsExpected)
         {
             CurrentSection = CreateSectionFromName(Buffer.ToString());
             Buffer.Clear();
             ParserState = ExpectCarriageReturn;
         }
         else if (NumberOfClosingBracketsExpected > 0)
         {
             --NumberOfClosingBracketsExpected;
             Buffer.Append(c);
         }
         else
         {
             throw SyntaxError("Too many closing square brackets");
         }
     }
     else
     {
         Buffer.Append(c);
     }
 }
Beispiel #2
0
 /// <summary>
 /// The default constructor creates a root section (typically a IniFile instance) and a set of parse options
 /// </summary>
 /// <param name="rootSection">Root section</param>
 /// <param name="options">Parse options</param>
 public IniFileParser(
     IniFileSection rootSection,
     IniFileOptions options = IniFileOptions.KeepComments | IniFileOptions.KeepFlat | IniFileOptions.StripEmptyLines)
 {
     RootSection           = rootSection;
     Options               = options;
     CurrentSection        = rootSection;
     CreateSectionFromName = CreateFlatSectionFromName;
 }
Beispiel #3
0
 /// <summary>
 /// This constructor creates a named section with a parent
 /// </summary>
 /// <param name="name">Name of this section</param>
 /// <param name="parent">Parent section. Must not be null</param>
 public IniFileSection(string name, IniFileSection parent)
 {
     Name   = name;
     Parent = parent;
     Parent.Sections.Add(this);
 }
Beispiel #4
0
 /// <summary>
 /// The default constructor creates an unamed section without a parent. Used only by the public IniFile constructor.
 /// </summary>
 protected IniFileSection()
 {
     Name   = null;
     Parent = null;
 }