#region CPL License
/*
Nuclex Framework
Copyright (C) 2002-2014 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using Nuclex.Support.Parsing;
namespace Nuclex.Support.Settings {
/// Represents an ini- or cfg-like configuration file
///
/// This class tries its best to preserve the formatting of configuration files.
/// Changing a value will keep the line it appears in intact.
///
public partial class ConfigurationFileStore : ISettingsStore {
#region class Category
/// 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;
}
#endregion // class Category
#region class Option
/// Stores informations about an option found in the configuration file
private class Option {
/// Index of the line the option is defined in
public int LineIndex;
/// Name of the option as a string
public StringSegment OptionName;
/// Value of the option as a string
public StringSegment OptionValue;
}
#endregion // class Option
/// Initializes a new, empty configuration file
public ConfigurationFileStore() {
this.lines = new List();
this.categories = new List();
this.options = new List