DataDirectoryEntry Pennington.Data
Singleton holder for a directory of data files, aggregating every .yml, .yaml, and .json file into one list of TItem. The first call to GetValue enumerates the directory and deserializes each file via DataFileLoader; subsequent calls return the cached list until FileWatchDispatcher reports a change in the directory, at which point the next access reloads it.
Properties
Namestring- Logical name supplied at registration; lookup key for
Get. ValueTypeType- The closed generic type the entry was registered with.
WatchScopesIReadOnlyList<FileWatchScope>- Directories needing an OS-level watcher. Empty (the default) for aggregators that ride notifications other watchers already produce.
Constructors
DataDirectoryEntry
#public DataDirectoryEntry`1(string name, string path, IFileSystem fileSystem)
Creates the entry; the directory itself is not read until GetValue is called.
Parameters
namestring- Logical name; the lookup key for
Get. pathstring- Path to the directory. Resolved against the current working directory if relative.
fileSystemIFileSystem- Abstraction used to enumerate and read the files.
Methods
GetValue
#public object GetValue()
Returns the current loaded value, refreshed if the underlying file has changed since last access.
Returns
objectOnFileChanged
#public FileWatchResponse OnFileChanged(FileChangeNotification change)
Called on the file-watcher thread for every watched change. Must be quick and thread-safe.
Parameters
changeFileChangeNotification
Returns
FileWatchResponsePennington.Data.DataDirectoryEntry
namespace Pennington.Data;
/// Singleton holder for a directory of data files, aggregating every .yml, .yaml, and .json file into one list of TItem. The first call to GetValue enumerates the directory and deserializes each file via DataFileLoader; subsequent calls return the cached list until FileWatchDispatcher reports a change in the directory, at which point the next access reloads it.
public class DataDirectoryEntry
{
/// Creates the entry; the directory itself is not read until GetValue is called.
public DataDirectoryEntry`1(string name, string path, IFileSystem fileSystem)
;
/// Returns the current loaded value, refreshed if the underlying file has changed since last access.
public object GetValue()
;
/// Logical name supplied at registration; lookup key for Get.
public string Name { get; }
/// Called on the file-watcher thread for every watched change. Must be quick and thread-safe.
public FileWatchResponse OnFileChanged(FileChangeNotification change)
;
/// The closed generic type the entry was registered with.
public Type ValueType { get; }
/// Directories needing an OS-level watcher. Empty (the default) for aggregators that ride notifications other watchers already produce.
public IReadOnlyList<FileWatchScope> WatchScopes { get; }
}