Method AddFileRepoCleaner
AddFileRepoCleaner(IServiceCollection, Action<FileRepoCleaningOptions>?)
Registers a FileRepoCleaner as a singleton, created from the FileRepoCleaningOptions of the options system, and as the IFileRepoCleaner of the application.
Declaration
public static IServiceCollection AddFileRepoCleaner(this IServiceCollection services, Action<FileRepoCleaningOptions>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceCollection | services | The service collection to add the services to. |
| Action<FileRepoCleaningOptions> | configure | An optional action to configure options. BaseDirectory must be set, here or through configuration. |
Returns
| Type | Description |
|---|---|
| IServiceCollection |
Remarks
The options are validated when the application starts and frozen when the cleaner is created, the first time one of these services is resolved. The application fails to start if the options are not valid, such as when the base directory is not set. The OptionsValidationException lists every problem.
A service that is already registered is kept, so calling this again only adds configure, and IFileRepoCleaner stays
a FileRepo that was registered first (see AddFileRepo(IServiceCollection, Action<FileRepoOptions>?)).