Class BaseKeyValueParser
The base parser for key-value configuration and translation files (ini and toml).
public abstract class BaseKeyValueParser : BaseParser
- Inheritance
-
BaseKeyValueParser
- Derived
- Inherited Members
Properties
LineCommentChar
protected virtual char LineCommentChar { get; }
Property Value
LocaleSeparatorChar
Gets or sets the character that is used to separate the locale name from the base name in the names of locale-specific translation files.
public static char LocaleSeparatorChar { get; set; }
Property Value
Methods
AcceptUnquotedEmptyValues()
protected abstract bool AcceptUnquotedEmptyValues()
Returns
GetLocaleSeparatorChar()
Used for internal needs.
public override char GetLocaleSeparatorChar()
Returns
- char
The character, used to separate the base file name and the locale.
InternalLoadTranslationStructure(string, TextFormat?)
Loads the keys from the default translation file and builds a tree of keys.
protected override TranslationTree? InternalLoadTranslationStructure(string content, TextFormat? textProcessingMode)
Parameters
contentstringThe content to parse.
textProcessingModeTextFormat?The mode of processing of the text of the default file.
Returns
- TranslationTree
The constructed TranslationTree upon success or null otherwise.
Exceptions
- TextParseException
Gets thrown when parsing of a default translation file fails.
IsEndOfKey(string, int, out int)
protected abstract bool? IsEndOfKey(string content, int offset, out int newPosition)
Parameters
Returns
- bool?
IsEndOfValue(string, int, out int)
Detects if the end of a value has been reached.
protected abstract bool? IsEndOfValue(string content, int offset, out int newPosition)
Parameters
contentstringcontent to check.
offsetintcurrent position within the content.
newPositionintupon return is set to a position next to the end-of-value marker (indicates to which value the pointer must be set).
Returns
- bool?
true if the end of the value has been reached, false if the end has not been reached, and null if the end of line was encountered and a single-line value was not closed.
Exceptions
- TextParseException
thrown when an error occurs.
IsEscapedEOLInValue(string, int)
protected virtual bool IsEscapedEOLInValue(string content, int offset)
Parameters
Returns
IsSeparatorChar(char)
protected abstract bool IsSeparatorChar(char candidate)
Parameters
candidatechar
Returns
IsStartOfKey(string, int)
protected abstract bool IsStartOfKey(string content, int offset)
Parameters
Returns
IsStartOfValue(string, int, out int)
protected abstract bool IsStartOfValue(string content, int offset, out int posAfterStart)
Parameters
Returns
IsValidKeyChar(string, int)
protected virtual bool IsValidKeyChar(string content, int offset)
Parameters
Returns
IsValidSectionNameChar(string, int)
protected virtual bool IsValidSectionNameChar(string content, int offset)
Parameters
Returns
LoadTranslation(string, CultureInfo?, TextFormat?)
Loads the translation information from the file and returns a translation.
public override Translation? LoadTranslation(string translationText, CultureInfo? culture, TextFormat? textProcessingMode)
Parameters
translationTextstringThe text of the file to load.
cultureCultureInfoAn optional reference to the locale, whose translation is to be loaded. Makes sense for CSV and TSV formats that may contain multiple translations in one file.
textProcessingModeTextFormat?The mode of processing of the text of the translation file.
Returns
- Translation
The loaded translation or null if loading failed.
ParseConfiguration(string, Assembly?)
public override TranslationConfiguration? ParseConfiguration(string fileContent, Assembly? assembly)
Parameters
Returns
UnwrapKey(string)
Strips format-specific markers that denote the beginning and the end of a value.
protected abstract string UnwrapKey(string value)
Parameters
valuestringThe value to strip.
Returns
- string
The text inside the markers.
UnwrapValue(string)
Strips format-specific markers that denote the beginning and the end of a value.
protected abstract (string? escaped, string unescaped) UnwrapValue(string value)
Parameters
valuestringThe value to strip.