Show / Hide Table of Contents

Class IniAdapter

Helper methods to save a ValueStore to an Ini file and loading it back again.

Inheritance
System.Object
IniAdapter
Namespace: sttz.Trimmer
Assembly: Trimmer.dll
Syntax
public static class IniAdapter
Remarks

The ini file supports comments on lines starting with "#" or "//" but not trailing comments. Categories are not supported.

Each line assigns a value to an Option. The name part in front of the equal sign can contain child names separated by a dot and variant parameters enclosed with square brackets. Variant parameters must be quoted with double quotes if they contain square brackets (and double quotes then escaped).

The value after the equal sign will be trimmed. It can be quoted with double quotes to retain the white space.

Fields

| Improve this Doc View Source

LineRegex

Regex matching a line in a Ini file.

Declaration
public static readonly Regex LineRegex
Field Value
Type Description
System.Text.RegularExpressions.Regex
| Improve this Doc View Source

NameRegex

Regex matching only the name part of an ini line.

Declaration
public static readonly Regex NameRegex
Field Value
Type Description
System.Text.RegularExpressions.Regex

Methods

| Improve this Doc View Source

GetValue(String)

Get the value part of an ini line, unquoting where necessary.

Declaration
public static string GetValue(string iniLine)
Parameters
Type Name Description
System.String iniLine
Returns
Type Description
System.String
| Improve this Doc View Source

Load(ValueStore, String)

Load the values in an Ini file into this value store instance, replacing the value store's contents.

Declaration
public static void Load(ValueStore store, string content)
Parameters
Type Name Description
ValueStore store
System.String content
| Improve this Doc View Source

NameToPath(String)

Take the name part of an ini line and convert it to a option path that then can be used with GetOption(String).

Declaration
public static string NameToPath(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
System.String
| Improve this Doc View Source

QuoteParameterIfNeeded(String)

Quote a parameter if it contains square brackets or return it as-is otherwise.

Declaration
public static string QuoteParameterIfNeeded(string parameter)
Parameters
Type Name Description
System.String parameter
Returns
Type Description
System.String
| Improve this Doc View Source

QuoteValueIfNeeded(String)

Quote a value if it contains leading or trailing whitespace or return it as-is otherwise.

Declaration
public static string QuoteValueIfNeeded(string value)
Parameters
Type Name Description
System.String value
Returns
Type Description
System.String
| Improve this Doc View Source

Save(ValueStore)

Save the content of this value store as a Ini file formatted string.

Declaration
public static string Save(ValueStore store)
Parameters
Type Name Description
ValueStore store
Returns
Type Description
System.String
  • Improve this Doc
  • View Source
Back to top © 2017 Adrian Stutz