Added logging to module framework

Implemented logging to Adafruit and changed database loading behavior.
This commit is contained in:
2021-08-07 17:20:46 -05:00
parent c94ea4a624
commit 38ffb3c7e1
36 changed files with 304 additions and 240 deletions

View 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";
}
}
}

View File

@@ -0,0 +1,7 @@
namespace Props.Services.Content
{
public interface ITextualManager<out TModel>
{
dynamic Json { get; }
}
}