29 lines
861 B
C#
29 lines
861 B
C#
using System.IO;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Newtonsoft.Json.Linq;
|
|
using Props.Options;
|
|
|
|
namespace Props.Services.Content
|
|
{
|
|
public class CachedTextualManager<TPage> : ITextualManager<TPage>
|
|
{
|
|
private dynamic data;
|
|
private readonly TextualOptions options;
|
|
private readonly string fileName;
|
|
|
|
dynamic ITextualManager<TPage>.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<TextualOptions>();
|
|
this.fileName = typeof(TPage).Name.Replace("Model", "") + ".json";
|
|
}
|
|
}
|
|
} |