Table of Contents

Interface IOptionsLoader<TOptions>

Namespace
Acuit.Pinpoint.Workstation.Configuration
Assembly
Acuit.Pinpoint.Workstation.Interfaces.dll

Provides option-loading services used while processing changes to options.

[Obsolete("This is deprecated and will be removed in a future version; Acuit.Pinpoint.Workstation.Configuration.IOptionsRegistry should be used instead.")]
public interface IOptionsLoader<TOptions> where TOptions : class, new()

Type Parameters

TOptions

The options instance type.

Properties

ConfigurationSection

Gets the configuration section that corresponds to the options.

IConfigurationSection ConfigurationSection { get; }

Property Value

IConfigurationSection

HealthCheckResult

Gets the health check result, so far, for the options loading process.

HealthCheckResult HealthCheckResult { get; }

Property Value

HealthCheckResult

Remarks

This will reflect the first unhealthy-status health check problem recorded via RecordHealthCheckProblem(HealthCheckResult), or the first degraded-status health check problem recorded if no unhealthy-status problems have been recorded, or a Healthy result if no problems have been recorded.

Methods

RecordHealthCheckProblem(HealthCheckResult)

Records a health check problem.

void RecordHealthCheckProblem(HealthCheckResult healthCheckResult)

Parameters

healthCheckResult HealthCheckResult

The health check result.

Remarks

While processing a set of options due to configuration settings changes, only the first unhealthy-status health check problem recorded (or the first degraded-status health check problem recorded if no unhealthy-status problems are recorded) will eventually be surfaced as the health check problem. All subsequent problems recorded will be ignored (until processing options the next time configuration settings change).

RetrieveFileAsync(Expression<Func<TOptions, string>>)

Retrieves a file from Acuit Pinpoint Server.

[Obsolete("This is deprecated and will be removed in a future version; RetrieveFileAsync(string) should be used instead. For example: optionsLoader.RetrieveFileAsync(optionsLoader.ConfigurationSection.GetSectionFromSelector(...).Path)")]
Task<string> RetrieveFileAsync(Expression<Func<TOptions, string>> serverFileNameSettingSelector)

Parameters

serverFileNameSettingSelector Expression<Func<TOptions, string>>

A lambda expression that selects the string option property containing the server file name. See the remarks for GetSectionFromSelector<TOptions, TMember>(IConfigurationSection, Expression<Func<TOptions, TMember>>) for details about what expressions are supported.

Returns

Task<string>

A task that represents the asynchronous operation. The value of its Result property contains the local path to the retrieved file, or null if the server file name value is null or empty, or if the file could not be retrieved.

Remarks

If the server file name value is null or empty, null will be returned as the task result and no health check problem will be recorded.

If an error occurs while attempting to retrieve the file, no exception will be thrown, but the error will be recorded as a health check problem (i.e., RecordHealthCheckProblem(HealthCheckResult) will automatically get called), and null will be returned as the task result.

Exceptions

ArgumentNullException

serverFileNameSettingSelector is null.

InvalidOperationException

The serverFileNameSettingSelector lambda expression does not select a member via simple member accesses and/or constant int indexers.

RetrieveFileAsync(string)

Retrieves a file from Acuit Pinpoint Server.

Task<string> RetrieveFileAsync(string key)

Parameters

key string

The full configuration key path (i.e., not just the part of the key relative to ConfigurationSection).

Returns

Task<string>

A task that represents the asynchronous operation. The value of its Result property contains the local path to the retrieved file, or null if the server file name value is null or empty, or if the file could not be retrieved.

Remarks

If the server file name value is null or empty, null will be returned as the task result and no health check problem will be recorded.

If an error occurs while attempting to retrieve the file, no exception will be thrown, but the error will be recorded as a health check problem (i.e., RecordHealthCheckProblem(HealthCheckResult) will automatically get called), and null will be returned as the task result.

GetSectionFromSelector<TOptions, TMember>(IConfigurationSection, Expression<Func<TOptions, TMember>>) can be used to select the proper key. For example:

protected override async Task PrepareUpdatedOptionsAsync(TestOptions options, IOptionsLoader<TestOptions> optionsLoader)
{
    await base.PrepareUpdatedOptionsAsync(options, optionsLoader).ConfigureAwait(true);
    options.LocalSomeFileName = await optionsLoader.RetrieveFileAsync(
        optionsLoader.ConfigurationSection.GetSectionFromSelector((MyOptions o) => o.SomeFileName).Path).ConfigureAwait(true);
}

Exceptions

ArgumentNullException

key is null.