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