bloxstrap/Bloxstrap/Resource.cs
pizzaboxer 606aadda97
Turn DeployManager from singleton to helper
this really did not need to be oop lol
2023-04-29 23:55:43 +01:00

28 lines
786 B
C#

using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
namespace Bloxstrap
{
static class Resource
{
static readonly Assembly assembly = Assembly.GetExecutingAssembly();
static readonly string[] resourceNames = assembly.GetManifestResourceNames();
public static async Task<byte[]> Get(string name)
{
string path = resourceNames.Single(str => str.EndsWith(name));
using (Stream stream = assembly.GetManifestResourceStream(path)!)
{
using (MemoryStream memoryStream = new())
{
await stream.CopyToAsync(memoryStream);
return memoryStream.ToArray();
}
}
}
}
}