mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Add slight simplifications
This commit is contained in:
parent
f9ec5c1523
commit
baaaf4091f
@ -567,7 +567,7 @@ namespace Bloxstrap
|
||||
private static async Task CheckModPreset(bool condition, string location, string name)
|
||||
{
|
||||
string modFolderLocation = Path.Combine(Directories.Modifications, location);
|
||||
byte[] binaryData = string.IsNullOrEmpty(name) ? new byte[0] : await ResourceHelper.Get(name);
|
||||
byte[] binaryData = string.IsNullOrEmpty(name) ? Array.Empty<byte>() : await ResourceHelper.Get(name);
|
||||
|
||||
if (condition)
|
||||
{
|
||||
|
@ -5,15 +5,16 @@ namespace Bloxstrap.Helpers
|
||||
{
|
||||
internal class ResourceHelper
|
||||
{
|
||||
static Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
static string[] resourceNames = assembly.GetManifestResourceNames();
|
||||
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 MemoryStream())
|
||||
{
|
||||
using (MemoryStream memoryStream = new())
|
||||
{
|
||||
await stream.CopyToAsync(memoryStream);
|
||||
return memoryStream.ToArray();
|
||||
@ -21,3 +22,4 @@ namespace Bloxstrap.Helpers
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user