Implemented groundwork for search configuration.
This commit is contained in:
27
Props/Services/Content/CachedContentManager.cs
Normal file
27
Props/Services/Content/CachedContentManager.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Props.Services.Content
|
||||
{
|
||||
public class CachedContentManager<TPage> : IContentManager<TPage>
|
||||
{
|
||||
private dynamic data;
|
||||
private readonly string directory;
|
||||
private readonly string fileName;
|
||||
|
||||
dynamic IContentManager<TPage>.Json
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data == null) data = JValue.Parse(File.ReadAllText(Path.Combine(directory, fileName)));
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public CachedContentManager(string directory = "content")
|
||||
{
|
||||
this.directory = directory;
|
||||
this.fileName = typeof(TPage).Name.Replace("Model", "") + ".json";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user