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