using System.Reflection;
using System.Text.Json;
namespace MyWebLog.Themes.BitBadger;
///
/// A technology used in a solution
///
public class Technology
{
///
/// The name of the technology
///
public string Name { get; set; } = "";
///
/// Why this technology was used in this project
///
public string Purpose { get; set; } = "";
///
/// Whether this project currently uses this technology
///
public bool? IsCurrent { get; set; } = null;
}
///
/// Information about the solutions displayed on the front page
///
public class FrontPageInfo
{
///
/// Whether the solution should be on the front page sidebar
///
public bool Display { get; set; } = false;
///
/// The order in which this solution should be displayed
///
public byte? Order { get; set; } = null;
///
/// The description text for the front page sidebar
///
public string? Text { get; set; } = null;
}
///
/// Information about a solution
///
public class SolutionInfo
{
///
/// The name of the solution
///
public string Name { get; set; } = "";
///
/// The URL slug for the page for this solution
///
public string Slug { get; set; } = "";
///
/// The URL for the solution (not the page describing it)
///
public string Url { get; set; } = "";
///
/// The category into which this solution falls
///
public string Category { get; set; } = "";
///
/// A short summary of the solution
///
public string? Summary { get; set; } = null;
///
/// Whether this solution is inactive
///
public bool? IsInactive { get; set; } = null;
///
/// Whether this solution is active
///
public bool IsActive => !(IsInactive ?? false);
///
/// Whether a link should not be generated to the URL for this solution
///
public bool? DoNotLink { get; set; } = null;
///
/// Whether a link should be generated to this solution
///
public bool LinkToSite => !(DoNotLink ?? false);
///
/// Whether an "About" link should be generated for this solution
///
public bool? SkipAboutLink { get; set; } = null;
///
/// Whether an "About" link should be generated for this solution
///
public bool LinkToAboutPage => !(SkipAboutLink ?? false);
///
/// Whether to generate a link to an archive site
///
public bool? LinkToArchive { get; set; } = null;
///
/// The URL of the archive site for this solution
///
public string? ArchiveUrl { get; set; } = null;
///
/// Home page sidebar display information
///
public FrontPageInfo FrontPage { get; set; } = default!;
///
/// Technologies used for this solution
///
public ICollection Technologies { get; set; } = new List();
///
/// Cache for reading solution info
///
private static readonly Lazy?>> _slnInfo = new(() =>
{
var asm = Assembly.GetAssembly(typeof(SolutionInfo))
?? throw new ArgumentNullException("Could not load the containing assembly");
using var stream = asm.GetManifestResourceStream("MyWebLog.Themes.BitBadger.solutions.json")
?? throw new ArgumentNullException("Could not load the solution data");
return JsonSerializer.DeserializeAsync>(stream);
});
///
/// Get all known solutions
///
///
/// if any required object is null
public static async Task> GetAll() =>
await _slnInfo.Value ?? throw new ArgumentNullException("Could not deserialize solution data");
}