mirror of
https://github.com/bitwarden/server.git
synced 2024-11-25 12:45:18 +01:00
23 lines
648 B
C#
23 lines
648 B
C#
|
using System.Reflection;
|
|||
|
|
|||
|
namespace Bit.Billing.Test.Utilities;
|
|||
|
|
|||
|
public static class EmbeddedResourceReader
|
|||
|
{
|
|||
|
public static async Task<string> ReadAsync(string resourceType, string fileName)
|
|||
|
{
|
|||
|
var assembly = Assembly.GetExecutingAssembly();
|
|||
|
|
|||
|
await using var stream = assembly.GetManifestResourceStream($"Bit.Billing.Test.Resources.{resourceType}.{fileName}");
|
|||
|
|
|||
|
if (stream == null)
|
|||
|
{
|
|||
|
throw new Exception($"Failed to retrieve manifest resource stream for file: {fileName}.");
|
|||
|
}
|
|||
|
|
|||
|
using var reader = new StreamReader(stream);
|
|||
|
|
|||
|
return await reader.ReadToEndAsync();
|
|||
|
}
|
|||
|
}
|