Method AddFileRepo
AddFileRepo(IServiceCollection, Action<FileRepoOptions>?)
Registers a FileRepo as a singleton, created from the FileRepoOptions of the options system, and as the IFileRepo and IFileRepoCleaner of the application.
Declaration
public static IServiceCollection AddFileRepo(this IServiceCollection services, Action<FileRepoOptions>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceCollection | services | The service collection to add the services to. |
| Action<FileRepoOptions> | configure | An optional action to configure options. BaseDirectory and MinimumFormatVersion must be set, here or through configuration. |
Returns
| Type | Description |
|---|---|
| IServiceCollection |
Remarks
The options are validated when the application starts and frozen when the repository 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 a required option 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 FileRepoCleaner that was registered first (see AddFileRepoCleaner(IServiceCollection, Action<FileRepoCleaningOptions>?)). The repository is not opened: the application calls
EnsureCreated() or EnsureInitialized() itself. The service provider disposes the repository when it is
disposed.