27 lines
718 B
C#
27 lines
718 B
C#
|
using System.IO;
|
||
|
using Newtonsoft.Json.Linq;
|
||
|
|
||
|
namespace Props.Services
|
||
|
{
|
||
|
public class JsonContentManager<Page> : IContentManager<Page>
|
||
|
{
|
||
|
private dynamic data;
|
||
|
private readonly string directory;
|
||
|
private readonly string fileName;
|
||
|
|
||
|
dynamic IContentManager<Page>.Content
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (data == null) data = JValue.Parse(File.ReadAllText(Path.Combine(directory, fileName)));
|
||
|
return data;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public JsonContentManager(string directory = "Content")
|
||
|
{
|
||
|
this.directory = directory;
|
||
|
this.fileName = typeof(Page).Name.Replace("Model", "") + ".json";
|
||
|
}
|
||
|
}
|
||
|
}
|