Table of Contents

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 IConfiguration

The configuration to use as both source and target for placeholder resolution.

logger ILogger

Optional logger

useEmptyStringIfNotFound bool

Replace 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 string

the string containing one or more placeholders

config IConfiguration

the configuration used for finding replace values.

logger ILogger

optional logger

Returns

string

the supplied value with the placeholders replaced inline