Added logging to module framework
Implemented logging to Adafruit and changed database loading behavior.
This commit is contained in:
29
Props/Services/Textual/CachedTextualManager.cs
Normal file
29
Props/Services/Textual/CachedTextualManager.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
7
Props/Services/Textual/ITextualManager.cs
Normal file
7
Props/Services/Textual/ITextualManager.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Props.Services.Content
|
||||
{
|
||||
public interface ITextualManager<out TModel>
|
||||
{
|
||||
dynamic Json { get; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user