MutableNotableDateResourceProvider Class
Definition
- Namespace
- Bodu.Globalization.Calendar
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
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
resourceNotableDateResourceThe initial resource.
loggerILoggerThe logger that records resource reloads. null selects Instance.
Exceptions
- ArgumentNullException
resourceis 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
resourceNotableDateResourceThe resource that becomes current.
Exceptions
- ArgumentNullException
resourceis null.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |