remove fileprovider #3

Merged
nseguin merged 2 commits from dev into main 2024-02-25 18:59:42 -06:00

View file

@ -3,16 +3,12 @@ using System.Collections.Concurrent;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.FileProviders;
namespace NSeguin.Dev.Web.HeroIcons;
internal readonly record struct HeroIconParameters(HeroIconKind Kind, HeroIconVariant Variant)
{
private const string PathBase = "lib/heroicons";
private static readonly ConcurrentDictionary<HeroIconParameters, string> SvgCache = new();
private static IFileProvider FileProvider = new PhysicalFileProvider(PathBase);
public Task<string> GetSvgAsync()
{
@ -43,9 +39,7 @@ internal readonly record struct HeroIconParameters(HeroIconKind Kind, HeroIconVa
private async Task<string> LoadSvgAsync()
{
var path = GetPath();
await using var fileStream = FileProvider.GetFileInfo(path).CreateReadStream();
using var reader = new StreamReader(fileStream);
var svg = await reader.ReadToEndAsync();
var svg = await File.ReadAllTextAsync(path);
SvgCache.TryAdd(this, svg);
return svg;
}