diff --git a/Source/Settings/ConfigurationFileStore.Parsing.cs b/Source/Settings/ConfigurationFileStore.Parsing.cs
index 6500b89..6b15417 100644
--- a/Source/Settings/ConfigurationFileStore.Parsing.cs
+++ b/Source/Settings/ConfigurationFileStore.Parsing.cs
@@ -70,7 +70,6 @@ namespace Nuclex.Support.Settings {
/// Current parser state
/// Line that has been read
private static void parseLine(ParserState state, string line) {
- state.Store.lines.Add(line);
// If the line is empty, ignore it
int length = line.Length;
@@ -98,6 +97,8 @@ namespace Nuclex.Support.Settings {
} else {
parseOption(state, line, firstCharacterIndex);
}
+ state.Category.Lines.Add(line);
+
}
/// Parses a category definition encountered on a line
@@ -130,13 +131,12 @@ namespace Nuclex.Support.Settings {
// Now we know that the line holds a category definition and where exactly in
// the line the category name is located. Create the category.
state.Category = new Category() {
- LineIndex = state.Store.lines.Count - 1,
CategoryName = new StringSegment(
line, nameStartIndex, nameEndIndex - nameStartIndex + 1
),
- OptionLookup = new Dictionary()
+ OptionLookup = new Dictionary(),
+ Lines = new List()
};
- state.Store.categories.Add(state.Category);
state.Store.categoryLookup.Add(state.Category.CategoryName.ToString(), state.Category);
}
@@ -160,7 +160,7 @@ namespace Nuclex.Support.Settings {
// We have enough information to know that this is an assignment of some kind
Option option = new Option() {
- LineIndex = state.Store.lines.Count - 1,
+ LineIndex = state.Category.Lines.Count - 1,
OptionName = new StringSegment(
line, firstCharacterIndex, nameEndIndex - firstCharacterIndex + 1
)
diff --git a/Source/Settings/ConfigurationFileStore.Test.cs b/Source/Settings/ConfigurationFileStore.Test.cs
index 4d36eaf..ceab195 100644
--- a/Source/Settings/ConfigurationFileStore.Test.cs
+++ b/Source/Settings/ConfigurationFileStore.Test.cs
@@ -209,6 +209,17 @@ namespace Nuclex.Support.Settings {
);
}
+ ///
+ /// Verifies that options can be added to the configuration file
+ ///
+ [Test]
+ public void OptionsCanBeAdded() {
+ var configurationFile = new ConfigurationFileStore();
+
+ configurationFile.Set(null, "test", "123");
+ Assert.That(configurationFile.Get(null, "test"), Is.EqualTo("123"));
+ }
+
}
} // namespace Nuclex.Support.Settings
diff --git a/Source/Settings/ConfigurationFileStore.cs b/Source/Settings/ConfigurationFileStore.cs
index fa15b6d..5bdb88f 100644
--- a/Source/Settings/ConfigurationFileStore.cs
+++ b/Source/Settings/ConfigurationFileStore.cs
@@ -37,15 +37,15 @@ namespace Nuclex.Support.Settings {
/// Stores informations about a category found in the configuration file
private class Category {
- /// Index of the line the category is defined in
- public int LineIndex;
-
/// Name of the category as a string
public StringSegment CategoryName;
/// Lookup table for the options in this category
public IDictionary OptionLookup;
+ /// Lines this category and its options consist of
+ public IList Lines;
+
}
#endregion // class Category
@@ -70,30 +70,31 @@ namespace Nuclex.Support.Settings {
/// Initializes a new, empty configuration file
public ConfigurationFileStore() {
- this.lines = new List();
- this.categories = new List();
this.options = new List