using System.IO; using Microsoft.Extensions.Configuration; using Newtonsoft.Json.Linq; using Props.Options; namespace Props.Services.Content { public class CachedContentManager : IContentManager { private dynamic data; private readonly ContentOptions options; private readonly string fileName; dynamic IContentManager.Json { get { if (data == null) data = JValue.Parse(File.ReadAllText(Path.Combine(options.Dir, fileName))); return data; } } public CachedContentManager(IConfiguration configuration) { this.options = configuration.GetSection(ContentOptions.Content).Get(); this.fileName = typeof(TPage).Name.Replace("Model", "") + ".json"; } } }