Table of Contents

Interface IOptionsLoader

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

Provides option-loading services used while initializing options.

public interface IOptionsLoader
Extension Methods

Properties

Configuration

Gets the root of the IConfiguration hierarchy containing ConfigurationSection.

IConfigurationRoot Configuration { get; }

Property Value

IConfigurationRoot

Remarks

This might be null, depending on the implementation (e.g., for IDeviceRegistry registrations that don't use configuration settings).

ConfigurationSection

Gets the configuration section that corresponds to the options.

IConfigurationSection ConfigurationSection { get; }

Property Value

IConfigurationSection

Remarks

This might be null, depending on the implementation (e.g., for IDeviceRegistry registrations that don't use configuration settings).

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(string)

Retrieves a file specified by a configuration setting.

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

The value of the configuration setting specified by key is assumed to contain an the absolute path to a file.

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

If the setting is defined from a configuration source on Acuit Pinpoint Server (e.g., the line configuration XML), then the file name is assumed to be a path on the Acuit Pinpoint Server computer. If the setting is defined from a local configuration source (e.g., a settings.json file defined on the workstation computer), then the file name will be assumed to be a path on the local workstation computer.

Paths can include environment variables quoted with the percent sign character (%) (e.g., %PLUGINSROOT%\PluginName.zip). Environment variables are expanded at the context within which the configuration setting is defined (i.e., on the Acuit Pinpoint Server computer versus the local workstation).

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:

string localFileName = await optionsLoader.RetrieveFileAsync(
    optionsLoader.ConfigurationSection.GetSectionFromSelector((MyOptions o) => o.SomeFileName).Path).ConfigureAwait(true);

Exceptions

ArgumentNullException

key is null.