Table of Contents

MutableNotableDateResourceProvider Class

Definition

Namespace
Bodu.Globalization.Calendar
Assembly
Bodu.Globalization.Calendar.dll
Package
Bodu.Globalization.Calendar 1.0.1
Source
MutableNotableDateResourceProvider.cs

An INotableDateResourceProvider whose resource can be replaced at runtime, so a long-lived service observes new data after a reload.

public sealed class MutableNotableDateResourceProvider : INotableDateResourceProvider
Inheritance
MutableNotableDateResourceProvider
Implements
Inherited Members
Extension Methods

Examples

MutableNotableDateResourceProvider provider = new(NotableDateResourceLoader.Load(initialXml));
INotableDateService service = new ReloadableNotableDateService(provider);

// Later, when the source document changes, swap in fresh data; the service picks it up
// on its next query without being rebuilt.
provider.Reload(NotableDateResourceLoader.Load(updatedXml));

Remarks

The current resource is swapped atomically; a ReloadableNotableDateService built over the provider rebuilds its resolution state the next time it is queried. Because a resource is itself immutable, applying new override operations or refreshed data at runtime is performed by loading a fresh NotableDateResource and passing it to Reload(NotableDateResource).

Logging. The constructor accepts an optional ILogger (defaulting to Instance, so logging is opt-in). When supplied, Reload(NotableDateResource) records the swap at Information, naming the resource that becomes current. This level is fixed.

Constructors

MutableNotableDateResourceProvider(NotableDateResource, ILogger?)

Initializes a new instance of the MutableNotableDateResourceProvider class.

public MutableNotableDateResourceProvider(NotableDateResource resource, ILogger? logger = null)

Parameters

resource NotableDateResource

The initial resource.

logger ILogger

The logger that records resource reloads. null selects Instance.

Exceptions

ArgumentNullException

resource is null.

Properties

Current

Gets the resource currently in effect.

public NotableDateResource Current { get; }

Property Value

NotableDateResource

The current NotableDateResource.

Methods

Reload(NotableDateResource)

Replaces the resource currently in effect.

public void Reload(NotableDateResource resource)

Parameters

resource NotableDateResource

The resource that becomes current.

Exceptions

ArgumentNullException

resource is null.

Applies to

ProductVersions
.NET8, 10

See Also