Table of Contents

Class RandomValueProvider

Namespace
Steeltoe.Extensions.Configuration
Assembly
Steeltoe.Extensions.Configuration.RandomValueBase.dll

Configuration provider that provides random values. Note: This code was inspired by the Spring Boot equivalent class.

public class RandomValueProvider : ConfigurationProvider, IConfigurationProvider
Inheritance
RandomValueProvider
Implements
Inherited Members

Constructors

RandomValueProvider(string, ILoggerFactory)

Initializes a new instance of the RandomValueProvider class. The new placeholder resolver wraps the provided configuration

public RandomValueProvider(string prefix, ILoggerFactory logFactory = null)

Parameters

prefix string

key prefix to use to match random number keys

logFactory ILoggerFactory

the logger factory to use

Methods

GetChildKeys(IEnumerable<string>, string)

Returns an empty list.

public override IEnumerable<string> GetChildKeys(IEnumerable<string> earlierKeys, string parentPath)

Parameters

earlierKeys IEnumerable<string>

The child keys returned by the preceding providers for the same parent path.

parentPath string

The parent path.

Returns

IEnumerable<string>

The child keys.

Load()

Creates a new underlying Random number generator.

public override void Load()

Set(string, string)

Sets a configuration value for the specified key. Currently ignored.

public override void Set(string key, string value)

Parameters

key string

The key.

value string

The value.

TryGet(string, out string)

Tries to get a configuration value for the specified key. If the key starts with the configured prefix (default random:), then the key will be parsed and the appropriate random value will be generated.

public override bool TryGet(string key, out string value)

Parameters

key string

The key which should start with prefix

value string

The random value returned

Returns

bool

True if a value for the specified key was found, otherwise false.