|
PeanutButter
|
Public Member Functions | |||||||
| INIFile () | |||||||
| Constructs an instance of INIFile without parsing any files, defaulting to best effort parser. | |||||||
| INIFile (string path) | |||||||
| Constructs an instance of INIFile, parsing the provided path if found, with the best-effort parser. | |||||||
| INIFile (ILineParser lineParser) | |||||||
| Constructs an instance of INIFile with a custom line parser. | |||||||
| INIFile (string path, ILineParser customLineParser) | |||||||
| Constructs an instance of INIFile with a custom line parser. | |||||||
| INIFile (string path, ParseStrategies parseStrategy) | |||||||
| Constructs an instance of INIFile, parsing the provided path if found, with escaped characters enabled if enableEscapeCharacters is true. | |||||||
| void | Load (string path) | ||||||
Attempts to load the file at the given path, discarding any existing config.
| |||||||
| void | Load (string path, Encoding encoding) | ||||||
Attempts to load the file at the given path, discarding any existing config.
| |||||||
| void | Load (string path, ParseStrategies parseStrategy) | ||||||
Attempts to load the file at the given path, discarding any existing config.
| |||||||
| void | Load (string path, ParseStrategies parseStrategy, Encoding encoding) | ||||||
Attempts to load the file at the given path, discarding any existing config.
| |||||||
| void | Parse (string contents) | ||||||
| Parses the string contents, loading as ini config. Will remove any prior config.
| |||||||
| IDictionary< string, string > | GetSection (string section) | ||||||
Retrieve the collection of settings for a section by section name.
| |||||||
| void | AddSection (string section, params string[] comments) | ||||||
Add a section by name.
| |||||||
| void | RemoveSection (string section) | ||||||
Remove a section by name.
| |||||||
| void | RenameSection (string existingName, string newName) | ||||||
Rename a section.
| |||||||
| void | Merge (string iniPath, MergeStrategies mergeStrategy) | ||||||
Merges in the ini config from the provided file path.
| |||||||
| void | Merge (IINIFile other, MergeStrategies mergeStrategy) | ||||||
Merges another ini file into this one.
| |||||||
| void | Reload () | ||||||
| Reload config (and all merged config) from disk. | |||||||
| void | Persist () | ||||||
| Persists to the last-loaded file, excluding merged configuration, with the default encoding. | |||||||
| void | Persist (Encoding encoding) | ||||||
Persists to the last-loaded file with the provided encoding.
| |||||||
| void | Persist (PersistStrategies persistStrategy) | ||||||
Persists to the last-loaded file with the specified merge strategy and default encoding.
| |||||||
| void | Persist (PersistStrategies persistStrategy, Encoding encoding) | ||||||
Persists to the last-loaded file with the specified merge strategy and encoding.
| |||||||
| void | Persist (string saveToPath) | ||||||
Persists to the specified path, excluding merged configuration, with the default encoding.
| |||||||
| void | Persist (string saveToPath, Encoding encoding) | ||||||
Persists to the specified path, excluding merged configuration, with the specified encoding.
| |||||||
| void | Persist (string saveToPath, PersistStrategies persistStrategy) | ||||||
Persists to the specified path with the specified strategy and default encoding.
| |||||||
| void | Persist (string saveToPath, PersistStrategies persistStrategy, Encoding encoding) | ||||||
Persists to the specified path with the specified strategy and the specified encoding.
| |||||||
| void | Persist (Stream toStream) | ||||||
Persists to the specified stream, excluding merged configuration, with the default encoding
| |||||||
| void | Persist (Stream toStream, Encoding encoding) | ||||||
Persists to the specified stream, excluding merged configuration, with the provided encoding
| |||||||
| void | Persist (Stream toStream, PersistStrategies persistStrategy) | ||||||
Persists to the specified stream, excluding merged configuration
| |||||||
| void | Persist (Stream toStream, PersistStrategies persistStrategy, Encoding encoding) | ||||||
Persists to the specified stream, using the provided persistence strategy and the provided encoding
| |||||||
| override string | ToString () | ||||||
| void | SetValue (string section, string key, string value) | ||||||
Sets a value by section and key.
| |||||||
| bool | RemoveValue (string section, string key) | ||||||
Removes a value from the section.
| |||||||
| bool | RemoveValue (string section, string key, bool removeEmptySection) | ||||||
Removes a value from the section.
| |||||||
| string | GetValue (string section, string key, string defaultValue=null) | ||||||
Get a configured value by section and key, optionally provide a fallback default value.
| |||||||
| bool | HasSection (string section) | ||||||
Test if a section exists by name.
| |||||||
| bool | HasSetting (string section, string key) | ||||||
Test if a setting exists by section and key.
| |||||||
Static Public Member Functions | |
| static INIFile | FromString (string ini) |
| Loads INI data from a string. | |
Properties | |||
| ParseStrategies | ParseStrategy = ParseStrategies.BestEffort [get, set] | ||
| Whether or not to handle escape characters in ini values When enabled (default), then the following sequences in values are supported: \ -> backslash " -> quote. | |||
| ILineParser | CustomLineParser [get, set] | ||
Provide a custom line parser if you like.
| |||
| string | SectionSeparator = "" [get, set] | ||
Separate sections with any string you like.
| |||
| bool | AppendTrailingNewLine = false [get, set] | ||
| Toggle whether a new line is added at the bottom when persisted. | |||
| bool | WrapValueInQuotes = true [get, set] | ||
| Toggle whether key values are wrapped in quote marks when persisted. | |||
| IEnumerable< string > | Sections [get] | ||
| List all the currently-available sections. | |||
| IEnumerable< string > | MergedSections [get] | ||
| Provides an enumeration over all merged section names. | |||
| IEnumerable< string > | AllSections [get] | ||
| Provides an enumeration over all section names: whether from merging or the initial load. | |||
| string | Path [get] | ||
| Exposes the path of the loaded INIFile. | |||
| Dictionary< string, IDictionary< string, string > > | Data [get] | ||
| Data storage for the current INI data. | |||
| Encoding | DefaultEncoding [get, set] | ||
| The default encoding to use when persisting files. You may specify an encoding at persistence time too. | |||
| IDictionary< string, string > | this[string index] [get, set] | ||
Interface to treat IINIFile like a dictionary of dictionaries.
| |||
| PeanutButter.INI.INIFile.INIFile | ( | string | path | ) |
Constructs an instance of INIFile, parsing the provided path if found, with the best-effort parser.
| path | Path to an existing ini file. Will not error if not found, but will be used as the default path to persist to. |
| PeanutButter.INI.INIFile.INIFile | ( | ILineParser | lineParser | ) |
Constructs an instance of INIFile with a custom line parser.
| lineParser |
| PeanutButter.INI.INIFile.INIFile | ( | string | path, |
| ILineParser | customLineParser ) |
Constructs an instance of INIFile with a custom line parser.
| path | |
| customLineParser |
| PeanutButter.INI.INIFile.INIFile | ( | string | path, |
| ParseStrategies | parseStrategy ) |
Constructs an instance of INIFile, parsing the provided path if found, with escaped characters enabled if enableEscapeCharacters is true.
| path | Path to an existing ini file. Will not error if not found, but will be used as the default path to persist to. |
| parseStrategy |
| void PeanutButter.INI.INIFile.AddSection | ( | string | section, |
| params string[] | comments ) |
Add a section by name.
| section | Name of the section to add |
| comments | (Optional) comments for the section |
Implements PeanutButter.INI.IINIFile.
|
static |
| IDictionary< string, string > PeanutButter.INI.INIFile.GetSection | ( | string | section | ) |
Retrieve the collection of settings for a section by section name.
| name |
Implements PeanutButter.INI.IINIFile.
| string PeanutButter.INI.INIFile.GetValue | ( | string | section, |
| string | key, | ||
| string | defaultValue = null ) |
Get a configured value by section and key, optionally provide a fallback default value.
| section | |
| key | |
| defaultValue |
Implements PeanutButter.INI.IINIFile.
| bool PeanutButter.INI.INIFile.HasSection | ( | string | section | ) |
| bool PeanutButter.INI.INIFile.HasSetting | ( | string | section, |
| string | key ) |
Test if a setting exists by section and key.
| section | |
| key |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Load | ( | string | path | ) |
Attempts to load the file at the given path, discarding any existing config.
| path |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Load | ( | string | path, |
| Encoding | encoding ) |
Attempts to load the file at the given path, discarding any existing config.
| path | |
| encoding |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Load | ( | string | path, |
| ParseStrategies | parseStrategy ) |
Attempts to load the file at the given path, discarding any existing config.
| path | |
| parseStrategy |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Load | ( | string | path, |
| ParseStrategies | parseStrategy, | ||
| Encoding | encoding ) |
Attempts to load the file at the given path, discarding any existing config.
| path | |
| parseStrategy | |
| encoding |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Merge | ( | IINIFile | other, |
| MergeStrategies | mergeStrategy ) |
Merges another ini file into this one.
| other | other ini file |
| mergeStrategy | strategy to use when encountering conflicts |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Merge | ( | string | iniPath, |
| MergeStrategies | mergeStrategy ) |
Merges in the ini config from the provided file path.
| iniPath | File to merge in to current config |
| mergeStrategy | Strategy to pick when merging |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Parse | ( | string | contents | ) |
Parses the string contents, loading as ini config.
Will remove any prior config.
| contents |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | ) |
Persists to the last-loaded file, excluding merged configuration, with the default encoding.
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | Encoding | encoding | ) |
Persists to the last-loaded file with the provided encoding.
| encoding |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | PersistStrategies | persistStrategy | ) |
Persists to the last-loaded file with the specified merge strategy and default encoding.
| persistStrategy | Strategy to employ for merged config |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | PersistStrategies | persistStrategy, |
| Encoding | encoding ) |
Persists to the last-loaded file with the specified merge strategy and encoding.
| persistStrategy | Strategy to employ for merged config |
| encoding | The encoding to use for the written file |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | Stream | toStream | ) |
Persists to the specified stream, excluding merged configuration, with the default encoding
| toStream | Stream to persist to |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | Stream | toStream, |
| Encoding | encoding ) |
Persists to the specified stream, excluding merged configuration, with the provided encoding
| toStream | Stream to persist to |
| encoding | Encoding to use |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | Stream | toStream, |
| PersistStrategies | persistStrategy ) |
Persists to the specified stream, excluding merged configuration
| toStream | Stream to persist to |
| persistStrategy | Strategy to employ for merged config |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | Stream | toStream, |
| PersistStrategies | persistStrategy, | ||
| Encoding | encoding ) |
Persists to the specified stream, using the provided persistence strategy and the provided encoding
| toStream | Stream to persist to |
| persistStrategy | Strategy to employ for merged config |
| encoding | Encoding to use |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | string | saveToPath | ) |
Persists to the specified path, excluding merged configuration, with the default encoding.
| saveToPath |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | string | saveToPath, |
| Encoding | encoding ) |
Persists to the specified path, excluding merged configuration, with the specified encoding.
| saveToPath | |
| encoding | Encoding to use |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | string | saveToPath, |
| PersistStrategies | persistStrategy ) |
Persists to the specified path with the specified strategy and default encoding.
| saveToPath | File to save to |
| persistStrategy | Strategy to employ for merged config |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Persist | ( | string | saveToPath, |
| PersistStrategies | persistStrategy, | ||
| Encoding | encoding ) |
Persists to the specified path with the specified strategy and the specified encoding.
| saveToPath | File to save to |
| persistStrategy | Strategy to employ for merged config |
| encoding | Encoding to use when writing the file |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.Reload | ( | ) |
Reload config (and all merged config) from disk.
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.RemoveSection | ( | string | section | ) |
| bool PeanutButter.INI.INIFile.RemoveValue | ( | string | section, |
| string | key ) |
Removes a value from the section.
| section | Section to remove the setting from |
| key | Setting to remove |
Implements PeanutButter.INI.IINIFile.
| bool PeanutButter.INI.INIFile.RemoveValue | ( | string | section, |
| string | key, | ||
| bool | removeEmptySection ) |
Removes a value from the section.
| section | Section to remove the setting from |
| key | Setting to remove |
| removeEmptySection | Whether or not to clear out empty sections |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.RenameSection | ( | string | existingName, |
| string | newName ) |
Rename a section.
| existingName | Name of the existing section |
| newName | New name of the section that is to be renamed |
Implements PeanutButter.INI.IINIFile.
| void PeanutButter.INI.INIFile.SetValue | ( | string | section, |
| string | key, | ||
| string | value ) |
|
get |
Provides an enumeration over all section names: whether from merging or the initial load.
Implements PeanutButter.INI.IINIFile.
|
getset |
Toggle whether a new line is added at the bottom when persisted.
Implements PeanutButter.INI.IINIFile.
|
getset |
Provide a custom line parser if you like.
Implements PeanutButter.INI.IINIFile.
|
getprotected |
Data storage for the current INI data.
|
getset |
The default encoding to use when persisting files. You may specify an encoding at persistence time too.
Implements PeanutButter.INI.IINIFile.
|
get |
Provides an enumeration over all merged section names.
Implements PeanutButter.INI.IINIFile.
|
getset |
Whether or not to handle escape characters in ini values When enabled (default), then the following sequences in values are supported: \ -> backslash " -> quote.
Implements PeanutButter.INI.IINIFile.
|
get |
Exposes the path of the loaded INIFile.
Implements PeanutButter.INI.IINIFile.
|
get |
List all the currently-available sections.
Implements PeanutButter.INI.IINIFile.
|
getset |
Separate sections with any string you like.
Implements PeanutButter.INI.IINIFile.
|
getset |
Interface to treat IINIFile like a dictionary of dictionaries.
| index |
Implements PeanutButter.INI.IINIFile.
|
getset |
Toggle whether key values are wrapped in quote marks when persisted.
Implements PeanutButter.INI.IINIFile.