Add project files.

This commit is contained in:
2025-05-21 19:39:09 -04:00
parent 7d2b71fe95
commit ec1713c95f
27 changed files with 5843 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
using System.Reflection;
using System.Text;
namespace MangaReader.Tests.Utilities;
public static class ResourceHelper
{
/// <summary>
/// Reads an embedded JSON resource from the calling assembly.
/// </summary>
/// <param name="resourceName">The full resource name, e.g. "MyNamespace.Folder.sample.json".</param>
public static async Task<string> ReadJsonResourceAsync(string resourceName)
{
Assembly assmbly = Assembly.GetExecutingAssembly();
using Stream? stream = assmbly.GetManifestResourceStream(resourceName)
?? throw new FileNotFoundException($"Resource '{resourceName}' not found.");
using StreamReader reader = new(stream, Encoding.UTF8);
return await reader.ReadToEndAsync();
}
}