I am developing a custom provider to for AWS System Manager Parameter Store.
I am running into an issue with LazyInitialization:
protected override void LazyInitialize(string name, NameValueCollection config)
{
Debug.WriteLine($"Entry:{nameof(ParameterStoreConfigBuilder)}:{nameof(LazyInitialize)}");
Optional = true;
base.LazyInitialize(name, config);
string env = UpdateConfigSettingWithAppSettings(envTag);
if (string.IsNullOrWhiteSpace(env))
throw new ArgumentException($"environment must be specified with the '{envTag}' attribute.");
environment = env;
string appName = UpdateConfigSettingWithAppSettings(appNameTag);
if (string.IsNullOrWhiteSpace(appName))
throw new ArgumentException($"appName must be specified with the '{appNameTag}' attribute.");
this.appname = appName;
this.tenant = UpdateConfigSettingWithAppSettings(tenantTag);
client = new AmazonSimpleSystemsManagementClient();
Debug.Assert(client != null);
Debug.WriteLine($"Exit:{nameof(ParameterStoreConfigBuilder)}:{nameof(LazyInitialize)}");
}
As soon we try to create a new client = new AmazonSimpleSystemsManagementClient();
The underlying code wants to read app.config that immediately causes GetValue(string key) to be fired, however, the client has not been created yet.
Is there a way to suppress firing GetValue(string key) until LazyInitialization has completed.
The GetValue
public override string GetValue(string key)
{
var name = $"/{environment}/{appname}/{key.Replace(':', '/')}";
Debug.WriteLine($"Entry:{nameof(ParameterStoreConfigBuilder)}:{nameof(GetValue)}:{name}");
Debug.Assert(client != null);
if (client == null)
return null;
var request = new GetParameterRequest
{
Name = name,
WithDecryption = true
};
var response = client.GetParameter(request);
var parameter = response.Parameter;
var value = parameter.Type == ParameterType.SecureString ? "*****" : parameter.Value;
Debug.WriteLine($"Exit:{nameof(ParameterStoreConfigBuilder)}:{nameof(GetValue)}:{name}={value}");
return value;
}
I am developing a custom provider to for AWS System Manager Parameter Store.
I am running into an issue with LazyInitialization:
As soon we try to create a new client = new AmazonSimpleSystemsManagementClient();
The underlying code wants to read app.config that immediately causes
GetValue(string key)to be fired, however, the client has not been created yet.Is there a way to suppress firing
GetValue(string key)until LazyInitialization has completed.The GetValue