Resolve a placeholder from a single KeyValuePair<string, object> argument.
The Key value pair source handles a KeyValuePair<string, object> value. When the selector matches the pair’s key, the source returns the pair’s value. It is a lightweight way to supply one named value without building a dictionary.
The key must be a string and the value must be an object. A pair with any other key or value type, such as KeyValuePair<string, int>, is not handled and the next source is tried. A null value resolves to an empty string. Use the nullable operator ({placeholder?.Anything}) to return an empty result instead of an error when the value is null.
The comparison is case-sensitive, so the selector must match the key exactly.
// "a value"
Smart.Format("{placeholder}", new KeyValuePair<string, object>("placeholder", "a value"));
| Smart String | Argument | Result |
|---|---|---|
{placeholder} |
KeyValuePair<string, object>("placeholder", "a value") |
a value |
{placeholder} |
KeyValuePair<string, object>("placeholder", null) |
(empty) |