2021-07-21 00:08:57 +00:00
|
|
|
using System.IO;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
2021-07-21 06:58:49 +00:00
|
|
|
namespace Props.Services.Content
|
2021-07-21 00:08:57 +00:00
|
|
|
{
|
2021-07-21 06:58:49 +00:00
|
|
|
public class ContentManager<Page> : IContentManager<Page>
|
2021-07-21 00:08:57 +00:00
|
|
|
{
|
|
|
|
private dynamic data;
|
|
|
|
private readonly string directory;
|
|
|
|
private readonly string fileName;
|
|
|
|
|
2021-07-21 06:58:49 +00:00
|
|
|
dynamic IContentManager<Page>.Json
|
2021-07-21 00:08:57 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (data == null) data = JValue.Parse(File.ReadAllText(Path.Combine(directory, fileName)));
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-21 06:58:49 +00:00
|
|
|
public ContentManager(string directory = "content")
|
2021-07-21 00:08:57 +00:00
|
|
|
{
|
|
|
|
this.directory = directory;
|
|
|
|
this.fileName = typeof(Page).Name.Replace("Model", "") + ".json";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|