PeanutButter
Loading...
Searching...
No Matches
PeanutButter.INI.IINIFile Interface Reference

Contract provided by the PeanutButter INI parser. More...

Inheritance diagram for PeanutButter.INI.IINIFile:
PeanutButter.INI.INIFile

Public Member Functions

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 AddSection (string section, params string[] comments)
 Add a section by name.
IDictionary< string, string > GetSection (string name)
 Retrieve the collection of settings for a section by section name.
void SetValue (string section, string key, string value)
 Sets a value by section and key.
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.
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 Parse (string contents)
 Parses the string contents, loading as ini config.
Will remove any prior config.
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

Parameters
toStreamStream to persist to

void Persist (Stream toStream, Encoding encoding)
 Persists to the specified stream, excluding merged configuration, with the provided encoding

Parameters
toStreamStream to persist to
encodingEncoding to use

void Persist (Stream toStream, PersistStrategies persistStrategy)
 Persists to the specified stream, excluding merged configuration

Parameters
toStreamStream to persist to
persistStrategyStrategy to employ for merged config

void Persist (Stream toStream, PersistStrategies persistStrategy, Encoding encoding)
 Persists to the specified stream, using the provided persistence strategy and the provided encoding

Parameters
toStreamStream to persist to
persistStrategyStrategy to employ for merged config
encodingEncoding to use

void Reload ()
 Reload config (and all merged config) from disk.
void Merge (IINIFile other, MergeStrategies mergeStrategy)
 Merges another ini file into this one.
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.

Properties

Encoding DefaultEncoding [get, set]
 The default encoding to use when persisting files. You may specify an encoding at persistence time too.
string SectionSeparator [get, set]
 Separate sections with any string you like.
bool AppendTrailingNewLine [get, set]
 Toggle whether a new line is added at the bottom when persisted.
bool WrapValueInQuotes [get, set]
 Toggle whether key values are wrapped in quote marks when persisted.
string Path [get]
 Exposes the path of the loaded INIFile.
IDictionary< string, string > this[string index] [get]
 Interface to treat IINIFile like a dictionary of dictionaries.
IEnumerable< string > Sections [get]
 List all the currently-available sections.
ParseStrategies ParseStrategy [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.
IEnumerable< string > AllSections [get]
 Provides an enumeration over all section names: whether from merging or the initial load.
IEnumerable< string > MergedSections [get]
 Provides an enumeration over all merged section names.
ILineParser CustomLineParser [get, set]
 Provide a custom line parser if you like.

Detailed Description

Contract provided by the PeanutButter INI parser.

Member Function Documentation

◆ AddSection()

void PeanutButter.INI.IINIFile.AddSection ( string section,
params string[] comments )

Add a section by name.

Parameters
sectionName of the section to add
comments(Optional) comments for the section

Implemented in PeanutButter.INI.INIFile.

◆ GetSection()

IDictionary< string, string > PeanutButter.INI.IINIFile.GetSection ( string name)

Retrieve the collection of settings for a section by section name.

Parameters
name
Returns

Implemented in PeanutButter.INI.INIFile.

◆ GetValue()

string PeanutButter.INI.IINIFile.GetValue ( string section,
string key,
string defaultValue = null )

Get a configured value by section and key, optionally provide a fallback default value.

Parameters
section
key
defaultValue
Returns

Implemented in PeanutButter.INI.INIFile.

◆ HasSection()

bool PeanutButter.INI.IINIFile.HasSection ( string section)

Test if a section exists by name.

Parameters
section
Returns

Implemented in PeanutButter.INI.INIFile.

◆ HasSetting()

bool PeanutButter.INI.IINIFile.HasSetting ( string section,
string key )

Test if a setting exists by section and key.

Parameters
section
key
Returns

Implemented in PeanutButter.INI.INIFile.

◆ Load() [1/4]

void PeanutButter.INI.IINIFile.Load ( string path)

Attempts to load the file at the given path, discarding any existing config.

Parameters
path

Implemented in PeanutButter.INI.INIFile.

◆ Load() [2/4]

void PeanutButter.INI.IINIFile.Load ( string path,
Encoding encoding )

Attempts to load the file at the given path, discarding any existing config.

Parameters
path
encoding

Implemented in PeanutButter.INI.INIFile.

◆ Load() [3/4]

void PeanutButter.INI.IINIFile.Load ( string path,
ParseStrategies parseStrategy )

Attempts to load the file at the given path, discarding any existing config.

Parameters
path
parseStrategy

Implemented in PeanutButter.INI.INIFile.

◆ Load() [4/4]

void PeanutButter.INI.IINIFile.Load ( string path,
ParseStrategies parseStrategy,
Encoding encoding )

Attempts to load the file at the given path, discarding any existing config.

Parameters
path
parseStrategy
encoding

Implemented in PeanutButter.INI.INIFile.

◆ Merge() [1/2]

void PeanutButter.INI.IINIFile.Merge ( IINIFile other,
MergeStrategies mergeStrategy )

Merges another ini file into this one.

Parameters
otherother ini file
mergeStrategystrategy to use when encountering conflicts

Implemented in PeanutButter.INI.INIFile.

◆ Merge() [2/2]

void PeanutButter.INI.IINIFile.Merge ( string iniPath,
MergeStrategies mergeStrategy )

Merges in the ini config from the provided file path.

  • ignores paths which don't exist
Parameters
iniPathFile to merge in to current config
mergeStrategyStrategy to pick when merging

Implemented in PeanutButter.INI.INIFile.

◆ Parse()

void PeanutButter.INI.IINIFile.Parse ( string contents)

Parses the string contents, loading as ini config.
Will remove any prior config.

Parameters
contents

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [1/12]

void PeanutButter.INI.IINIFile.Persist ( )

Persists to the last-loaded file, excluding merged configuration, with the default encoding.

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [2/12]

void PeanutButter.INI.IINIFile.Persist ( Encoding encoding)

Persists to the last-loaded file with the provided encoding.

Parameters
encoding

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [3/12]

void PeanutButter.INI.IINIFile.Persist ( PersistStrategies persistStrategy)

Persists to the last-loaded file with the specified merge strategy and default encoding.

Parameters
persistStrategyStrategy to employ for merged config

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [4/12]

void PeanutButter.INI.IINIFile.Persist ( PersistStrategies persistStrategy,
Encoding encoding )

Persists to the last-loaded file with the specified merge strategy and encoding.

Parameters
persistStrategyStrategy to employ for merged config
encodingThe encoding to use for the written file

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [5/12]

void PeanutButter.INI.IINIFile.Persist ( Stream toStream)

Persists to the specified stream, excluding merged configuration, with the default encoding

Parameters
toStreamStream to persist to

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [6/12]

void PeanutButter.INI.IINIFile.Persist ( Stream toStream,
Encoding encoding )

Persists to the specified stream, excluding merged configuration, with the provided encoding

Parameters
toStreamStream to persist to
encodingEncoding to use

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [7/12]

void PeanutButter.INI.IINIFile.Persist ( Stream toStream,
PersistStrategies persistStrategy )

Persists to the specified stream, excluding merged configuration

Parameters
toStreamStream to persist to
persistStrategyStrategy to employ for merged config

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [8/12]

void PeanutButter.INI.IINIFile.Persist ( Stream toStream,
PersistStrategies persistStrategy,
Encoding encoding )

Persists to the specified stream, using the provided persistence strategy and the provided encoding

Parameters
toStreamStream to persist to
persistStrategyStrategy to employ for merged config
encodingEncoding to use

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [9/12]

void PeanutButter.INI.IINIFile.Persist ( string saveToPath)

Persists to the specified path, excluding merged configuration, with the default encoding.

Parameters
saveToPath

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [10/12]

void PeanutButter.INI.IINIFile.Persist ( string saveToPath,
Encoding encoding )

Persists to the specified path, excluding merged configuration, with the specified encoding.

Parameters
saveToPath
encodingEncoding to use

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [11/12]

void PeanutButter.INI.IINIFile.Persist ( string saveToPath,
PersistStrategies persistStrategy )

Persists to the specified path with the specified strategy and default encoding.

Parameters
saveToPathFile to save to
persistStrategyStrategy to employ for merged config

Implemented in PeanutButter.INI.INIFile.

◆ Persist() [12/12]

void PeanutButter.INI.IINIFile.Persist ( string saveToPath,
PersistStrategies persistStrategy,
Encoding encoding )

Persists to the specified path with the specified strategy and the specified encoding.

Parameters
saveToPathFile to save to
persistStrategyStrategy to employ for merged config
encodingEncoding to use when writing the file

Implemented in PeanutButter.INI.INIFile.

◆ Reload()

void PeanutButter.INI.IINIFile.Reload ( )

Reload config (and all merged config) from disk.

Implemented in PeanutButter.INI.INIFile.

◆ RemoveSection()

void PeanutButter.INI.IINIFile.RemoveSection ( string section)

Remove a section by name.

Parameters
section

Implemented in PeanutButter.INI.INIFile.

◆ RemoveValue() [1/2]

bool PeanutButter.INI.IINIFile.RemoveValue ( string section,
string key )

Removes a value from the section.

  • will not remove empty sections
  • this is functionally equivalent to ini["section"].Remove("key")
Parameters
sectionSection to remove the setting from
keySetting to remove
Returns

Implemented in PeanutButter.INI.INIFile.

◆ RemoveValue() [2/2]

bool PeanutButter.INI.IINIFile.RemoveValue ( string section,
string key,
bool removeEmptySection )

Removes a value from the section.

  • optionally removes empty sections
Parameters
sectionSection to remove the setting from
keySetting to remove
removeEmptySectionWhether or not to clear out empty sections
Returns

Implemented in PeanutButter.INI.INIFile.

◆ RenameSection()

void PeanutButter.INI.IINIFile.RenameSection ( string existingName,
string newName )

Rename a section.

Parameters
existingNameName of the existing section
newNameNew name of the section that is to be renamed

Implemented in PeanutButter.INI.INIFile.

◆ SetValue()

void PeanutButter.INI.IINIFile.SetValue ( string section,
string key,
string value )

Sets a value by section and key.

Parameters
section
key
value

Implemented in PeanutButter.INI.INIFile.

Property Documentation

◆ AllSections

IEnumerable<string> PeanutButter.INI.IINIFile.AllSections
get

Provides an enumeration over all section names: whether from merging or the initial load.

Implemented in PeanutButter.INI.INIFile.

◆ AppendTrailingNewLine

bool PeanutButter.INI.IINIFile.AppendTrailingNewLine
getset

Toggle whether a new line is added at the bottom when persisted.

Implemented in PeanutButter.INI.INIFile.

◆ CustomLineParser

ILineParser PeanutButter.INI.IINIFile.CustomLineParser
getset

Provide a custom line parser if you like.

Implemented in PeanutButter.INI.INIFile.

◆ DefaultEncoding

Encoding PeanutButter.INI.IINIFile.DefaultEncoding
getset

The default encoding to use when persisting files. You may specify an encoding at persistence time too.

Implemented in PeanutButter.INI.INIFile.

◆ MergedSections

IEnumerable<string> PeanutButter.INI.IINIFile.MergedSections
get

Provides an enumeration over all merged section names.

Implemented in PeanutButter.INI.INIFile.

◆ ParseStrategy

ParseStrategies PeanutButter.INI.IINIFile.ParseStrategy
getset

Whether or not to handle escape characters in ini values When enabled (default), then the following sequences in values are supported: \ -> backslash " -> quote.

Implemented in PeanutButter.INI.INIFile.

◆ Path

string PeanutButter.INI.IINIFile.Path
get

Exposes the path of the loaded INIFile.

Implemented in PeanutButter.INI.INIFile.

◆ Sections

IEnumerable<string> PeanutButter.INI.IINIFile.Sections
get

List all the currently-available sections.

Implemented in PeanutButter.INI.INIFile.

◆ SectionSeparator

string PeanutButter.INI.IINIFile.SectionSeparator
getset

Separate sections with any string you like.

  • defaults to empty, which inserts a new line
  • set to null for no separator at all

Implemented in PeanutButter.INI.INIFile.

◆ this[string index]

IDictionary<string, string> PeanutButter.INI.IINIFile.this[string index]
get

Interface to treat IINIFile like a dictionary of dictionaries.

Parameters
index
Returns

Implemented in PeanutButter.INI.INIFile.

◆ WrapValueInQuotes

bool PeanutButter.INI.IINIFile.WrapValueInQuotes
getset

Toggle whether key values are wrapped in quote marks when persisted.

Implemented in PeanutButter.INI.INIFile.


The documentation for this interface was generated from the following file:
  • source/INI/PeanutButter.INI/INIFile.cs