Table of Contents

SqliteNotableDateCacheExtensions Class

Definition

Namespace
Bodu.Globalization.Calendar
Assembly
Bodu.Globalization.Calendar.Caching.Sqlite.dll
Package
Bodu.Globalization.Calendar.Caching.Sqlite 1.0.0
Source
SqliteNotableDateCacheExtensions.cs

Provides the fluent registration of a SQLite-backed notable-date cache onto an IServiceCollection.

public static class SqliteNotableDateCacheExtensions
Inheritance
SqliteNotableDateCacheExtensions
Inherited Members

Methods

AddSqliteNotableDateCache(IServiceCollection, IConfiguration?, string, Action<SqliteNotableDateCacheOptions>?)

Registers a SqliteNotableDateCache as the INotableDateCache used by the caching notable-date service.

public static IServiceCollection AddSqliteNotableDateCache(this IServiceCollection services, IConfiguration? configuration = null, string sectionName = "Calendar:NotableDateCache:Sqlite", Action<SqliteNotableDateCacheOptions>? configure = null)

Parameters

services IServiceCollection

The service collection to add the registration to.

configuration IConfiguration

An optional configuration root or section bound into SqliteNotableDateCacheOptions.

sectionName string

The configuration section name. Defaults to Calendar:NotableDateCache:Sqlite.

configure Action<SqliteNotableDateCacheOptions>

An optional callback applied after configuration binding.

Returns

IServiceCollection

The same service collection, to allow chaining.

Examples

services.AddNotableDateService(AmericasCalendarData.LoadResource("US"));
services.AddSqliteNotableDateCache(configure: o => o.DatabaseFilePath = "/var/cache/holidays.db");
services.AddCachedNotableDateService(cacheFactory: sp => sp.GetRequiredService<INotableDateCache>());

Remarks

The cache is registered as a singleton so its keep-alive connection is shared and the container disposes it on shutdown. Compose it with the caching service by resolving the registered cache - for example AddCachedNotableDateService(cacheFactory: sp => sp.GetRequiredService<INotableDateCache>()).

Exceptions

ArgumentNullException

Thrown when services is null.

ArgumentException

Thrown when sectionName is empty or white space.

Applies to

ProductVersions
.NET8, 10