Class PropertyPlaceholderHelper
- Namespace
- Steeltoe.Common.Configuration
- Assembly
- Steeltoe.Common.dll
Utility class for working with configuration values that have placeholders in them. A placeholder takes the form of
${some:config:reference?default_if_not_present}>
Note: This was "inspired" by the Spring class: PropertyPlaceholderHelper
public static class PropertyPlaceholderHelper
- Inheritance
-
PropertyPlaceholderHelper
- Inherited Members
Methods
GetResolvedConfigurationPlaceholders(IConfiguration, ILogger, bool)
Finds all placeholders of the form
${some:config:reference?default_if_not_present}
,
resolves them from other values in the configuration, returns a new list to add to your configuration.
public static IEnumerable<KeyValuePair<string, string>> GetResolvedConfigurationPlaceholders(IConfiguration config, ILogger logger = null, bool useEmptyStringIfNotFound = true)
Parameters
config
IConfigurationThe configuration to use as both source and target for placeholder resolution.
logger
ILoggerOptional logger
useEmptyStringIfNotFound
boolReplace the placeholder with an empty string, so the application does not see it
Returns
- IEnumerable<KeyValuePair<string, string>>
A list of keys with resolved values. Add to your ConfigurationBuilder with method 'AddInMemoryCollection'
ResolvePlaceholders(string, IConfiguration, ILogger)
Replaces all placeholders of the form
${some:config:reference?default_if_not_present}
with the corresponding value from the supplied IConfiguration.
public static string ResolvePlaceholders(string property, IConfiguration config, ILogger logger = null)
Parameters
property
stringthe string containing one or more placeholders
config
IConfigurationthe configuration used for finding replace values.
logger
ILoggeroptional logger
Returns
- string
the supplied value with the placeholders replaced inline