From baaaf4091fe69c89e80b91959068eb0720c266dd Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sun, 8 Jan 2023 14:59:52 +0000 Subject: [PATCH] Add slight simplifications --- Bloxstrap/Bootstrapper.cs | 2 +- Bloxstrap/Helpers/ResourceHelper.cs | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 665f2c6..f59f4f5 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -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() : await ResourceHelper.Get(name); if (condition) { diff --git a/Bloxstrap/Helpers/ResourceHelper.cs b/Bloxstrap/Helpers/ResourceHelper.cs index e6a4a36..f61776a 100644 --- a/Bloxstrap/Helpers/ResourceHelper.cs +++ b/Bloxstrap/Helpers/ResourceHelper.cs @@ -5,18 +5,20 @@ 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 Get(string name) { string path = resourceNames.Single(str => str.EndsWith(name)); using (Stream stream = assembly.GetManifestResourceStream(path)!) - using (MemoryStream memoryStream = new MemoryStream()) { - await stream.CopyToAsync(memoryStream); - return memoryStream.ToArray(); + using (MemoryStream memoryStream = new()) + { + await stream.CopyToAsync(memoryStream); + return memoryStream.ToArray(); + } } } }