NahidaImpact/NahidaImpact.Common/Data/Provider/LocalAssetProvider.cs
2024-01-04 16:48:39 +03:00

27 lines
881 B
C#

using System.Text.Json;
namespace NahidaImpact.Common.Data.Provider;
internal sealed class LocalAssetProvider : IAssetProvider
{
private const string ExcelDirectory = "assets/excel/";
private const string AvatarConfigDirectory = "assets/binout/avatar/";
public IEnumerable<string> EnumerateAvatarConfigFiles()
{
return Directory.GetFiles(AvatarConfigDirectory);
}
public JsonDocument GetFileAsJsonDocument(string fullPath)
{
using FileStream fileStream = new(fullPath, FileMode.Open, FileAccess.Read);
return JsonDocument.Parse(fileStream);
}
public JsonDocument GetExcelTableJson(string assetName)
{
string filePath = string.Concat(ExcelDirectory, assetName);
using FileStream fileStream = new(filePath, FileMode.Open, FileAccess.Read);
return JsonDocument.Parse(fileStream);
}
}