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)
|
private static async Task CheckModPreset(bool condition, string location, string name)
|
||||||
{
|
{
|
||||||
string modFolderLocation = Path.Combine(Directories.Modifications, location);
|
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)
|
if (condition)
|
||||||
{
|
{
|
||||||
|
@ -5,18 +5,20 @@ namespace Bloxstrap.Helpers
|
|||||||
{
|
{
|
||||||
internal class ResourceHelper
|
internal class ResourceHelper
|
||||||
{
|
{
|
||||||
static Assembly assembly = Assembly.GetExecutingAssembly();
|
static readonly Assembly assembly = Assembly.GetExecutingAssembly();
|
||||||
static string[] resourceNames = assembly.GetManifestResourceNames();
|
static readonly string[] resourceNames = assembly.GetManifestResourceNames();
|
||||||
|
|
||||||
public static async Task<byte[]> Get(string name)
|
public static async Task<byte[]> Get(string name)
|
||||||
{
|
{
|
||||||
string path = resourceNames.Single(str => str.EndsWith(name));
|
string path = resourceNames.Single(str => str.EndsWith(name));
|
||||||
|
|
||||||
using (Stream stream = assembly.GetManifestResourceStream(path)!)
|
using (Stream stream = assembly.GetManifestResourceStream(path)!)
|
||||||
using (MemoryStream memoryStream = new MemoryStream())
|
|
||||||
{
|
{
|
||||||
await stream.CopyToAsync(memoryStream);
|
using (MemoryStream memoryStream = new())
|
||||||
return memoryStream.ToArray();
|
{
|
||||||
|
await stream.CopyToAsync(memoryStream);
|
||||||
|
return memoryStream.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user