From 17bc0d18e9d71ff85353b1add2ddc74f2561bc09 Mon Sep 17 00:00:00 2001 From: Shawdooow Date: Sat, 20 Nov 2021 18:37:12 -0500 Subject: [PATCH] Use : to split assembly and resource --- vke/src/Utils.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/vke/src/Utils.cs b/vke/src/Utils.cs index 564e87c..82cbcf9 100644 --- a/vke/src/Utils.cs +++ b/vke/src/Utils.cs @@ -37,6 +37,7 @@ namespace Vulkan { } /// /// Return a file or embedded resource stream. + /// Use : to split assembly and resource (ex; Assembly:shader.vert.spv) /// /// The stream from path. /// The file or stream path. Embedded resource path starts with '#'. @@ -44,15 +45,17 @@ namespace Vulkan { if (path.StartsWith ("#", StringComparison.Ordinal)) { Stream stream = null; string resId = path.Substring (1); - if (tryFindResource (Assembly.GetEntryAssembly (), resId, out stream)) - return stream; - string[] assemblyNames = resId.Split ('.'); + string[] assemblyNames = resId.Split (':'); Assembly assembly = AppDomain.CurrentDomain.GetAssemblies ().FirstOrDefault (aa => aa.GetName ().Name == assemblyNames[0]); - if (assembly == null && assemblyNames.Length > 3) - assembly = AppDomain.CurrentDomain.GetAssemblies () - .FirstOrDefault (aa => aa.GetName ().Name == $"{assemblyNames[0]}.{assemblyNames[1]}"); - if (assembly != null && tryFindResource (assembly, resId, out stream)) - return stream; + if (assembly == null) + throw new Exception("Assembly not found: " + path); + else + { + if (tryFindResource(assembly, resId.Replace(':', '.'), out stream)) + return stream; + new Exception("Embedded resource not found in assembly: " + path); + } + throw new Exception ("Resource not found: " + path); } if (!File.Exists (path)) -- 2.47.3