Generic variable substitution library
$ dotnet add package DioRed.Common.VariableSubstitutionGeneric variable substitution library.
Supported syntaxes:
{var} (could be escaped by \{){{ var }} (no escape characters allowed)${var} (could be escaped by $${)Usage:
Dictionary<string, string> variables = new()
{
["var1"] = "value1"
};
VariableSubstitutor substitutor = new(
variables,
style: VariableStyle.DollarPrefixedSingleCurveBracket,
useEnvironmentVariables: true,
environmentVariablesPrefix: "MYAPP_"
// will look into MYAPP_var1 if var1 wasn't provided
);
string input = "value with ${var1} injected";
string replaced = substitutor.Substitute(input);
// value with value1 injected