DataFileServiceExtensions
Pennington.Data
DI helpers for registering YAML/JSON data files that hot-reload when the underlying file changes on disk.
Methods
AddDataDirectory<TItem>
#public static IServiceCollection AddDataDirectory<TItem>(IServiceCollection services, string name, string path)
Registers every .yml, .yaml, and .json file in path as a single aggregated IReadOnlyList accessible through IDataFiles under the lookup key name. Each file contributes one record, or several when its root is an array; files are ordered by name. Edits, additions, and removals in the directory invalidate the cached value so the next read returns the fresh content.
Parameters
servicesIServiceCollection- The service collection.
namestring- Logical lookup key. Case-insensitive; must be unique across all registered data files.
pathstring- Path to the directory. Resolved against the current working directory if relative.
Returns
IServiceCollectionAddDataFile<T>
#public static IServiceCollection AddDataFile<T>(IServiceCollection services, string name, string path)
Registers path as a data file accessible through IDataFiles under the lookup key name. Format is inferred from the file extension (.yml, .yaml, .json). Edits to the file invalidate the cached value so the next read returns the fresh content.
Parameters
servicesIServiceCollection- The service collection.
namestring- Logical lookup key. Case-insensitive; must be unique across all registered data files.
pathstring- Path to the data file. Resolved against the current working directory if relative.
Returns
IServiceCollectionPennington.Data.DataFileServiceExtensions
namespace Pennington.Data;
/// DI helpers for registering YAML/JSON data files that hot-reload when the underlying file changes on disk.
public class DataFileServiceExtensions
{
/// Registers every .yml, .yaml, and .json file in path as a single aggregated IReadOnlyList accessible through IDataFiles under the lookup key name. Each file contributes one record, or several when its root is an array; files are ordered by name. Edits, additions, and removals in the directory invalidate the cached value so the next read returns the fresh content.
public static IServiceCollection AddDataDirectory<TItem>(IServiceCollection services, string name, string path)
;
/// Registers path as a data file accessible through IDataFiles under the lookup key name. Format is inferred from the file extension (.yml, .yaml, .json). Edits to the file invalidate the cached value so the next read returns the fresh content.
public static IServiceCollection AddDataFile<T>(IServiceCollection services, string name, string path)
;
}