FileRateCacheOptions Class
Definition
- Namespace
- Bodu.Financial.ExchangeRates.Caching
- Assembly
- Bodu.Financial.ExchangeRates.Caching.dll
- Package
- Bodu.Financial.ExchangeRates.Caching 1.0.0
- Source
- FileRateCacheOptions.cs
Configures a file-backed IRateCache: the single provider inherited from RateCacheOptions together with the directory its cache files are written under.
public class FileRateCacheOptions : RateCacheOptions
- Inheritance
-
FileRateCacheOptions
- Inherited Members
- Extension Methods
Remarks
Expiry is not a storage concern - it is supplied per call by the caching provider - so this type carries only the storage location in addition to the bound provider.
Constructors
FileRateCacheOptions()
public FileRateCacheOptions()
Properties
CacheDirectory
Gets or sets the directory used by the on-disk cache.
public string? CacheDirectory { get; set; }
Property Value
Layout
Gets or sets the layout describing where a currency pair's rows are stored: the folder hierarchy, the file name, and whether the rows are split across files by date.
public RateCacheFileLayout Layout { get; set; }
Property Value
- RateCacheFileLayout
The file layout. Defaults to SingleFile, which stores a pair's whole history in one file under a per-provider folder.
Remarks
Use a built-in partitioned layout - Yearly, Monthly, or Daily - to split a pair's rows into per-period files, or Create(RateCachePartitionStrategy, Func<RateCacheDirectoryContext, string>?, Func<RateCacheFileContext, string>?) to supply custom folder and file-name rules and a custom RateCachePartitionStrategy.
Methods
TryValidate(out string?)
Attempts to validate the options without throwing, reporting the first invariant that is violated.
public override bool TryValidate(out string? error)
Parameters
errorstringWhen this method returns false, a message describing the first violated invariant; otherwise null.
Returns
Remarks
The dependency-injection registration wires this method into ValidateOnStart so misconfiguration fails
fast at application startup. It mirrors the invariants of Validate() but returns a message rather
than throwing with a ParamName. Storage-specific option types override this method to add their own
invariants after invoking the base implementation.
Validate()
Validates the option values, throwing when a rule is violated.
public override void Validate()
Remarks
This throwing form preserves the ParamName of the offending option, which callers rely on. The
dependency-injection registration instead wires TryValidate(out string?) into ValidateOnStart, which
reports the same invariants without throwing.
Exceptions
- ArgumentNullException
- ArgumentException
Thrown when Provider is empty or white space.
- ArgumentException
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |