public static Dictionary<string, string> ParseKeyValuePairs(
this string? value,
char parameterDelimiter = ';',
char keyValueDelimiter = '=',
char startValueDelimiter = '{',
char endValueDelimiter = '}',
bool ignoreDuplicateKeys = true
)
<ExtensionAttribute>
Public Shared Function ParseKeyValuePairs (
value As String,
Optional parameterDelimiter As Char = ";"C,
Optional keyValueDelimiter As Char = "="C,
Optional startValueDelimiter As Char = "{"C,
Optional endValueDelimiter As Char = "}"C,
Optional ignoreDuplicateKeys As Boolean = true
) As Dictionary(Of String, String)
public:
[ExtensionAttribute]
static Dictionary<String^, String^>^ ParseKeyValuePairs(
String^ value,
wchar_t parameterDelimiter = L';',
wchar_t keyValueDelimiter = L'=',
wchar_t startValueDelimiter = L'{',
wchar_t endValueDelimiter = L'}',
bool ignoreDuplicateKeys = true
)
Gemstone.StringExtensions.StringExtensions.ParseKeyValuePairs = function(value, parameterDelimiter, keyValueDelimiter, startValueDelimiter, endValueDelimiter, ignoreDuplicateKeys);
Parses a string containing key/value pair expressions (e.g., "localPort=5001; transportProtocol=UDP; interface=0.0.0.0"). This method treats all "keys" as case-insensitive. Nesting of key/value pair expressions is allowed by encapsulating the value using the startValueDelimiter and endValueDelimiter values (e.g., "dataChannel={Port=-1;Clients=localhost:8800}; commandChannel={Port=8900}; dataFormat=FloatingPoint;"). There must be one endValueDelimiter for each encountered startValueDelimiter in the value or a FormatException will be thrown. Multiple levels of nesting is supported. If the ignoreDuplicateKeys flag is set to false an ArgumentException will be thrown when all key parameters are not unique. Note that keys within nested expressions are considered separate key/value pair strings and are not considered when checking for duplicate keys.
ArgumentNullException | value is null. |
ArgumentException | All delimiters must be unique -or- all keys must be unique when ignoreDuplicateKeys is set to false. |
FormatException | Total nested key/value pair expressions are mismatched -or- encountered endValueDelimiter before startValueDelimiter. |