From: Shawdooow Date: Sat, 20 Nov 2021 23:37:12 +0000 (-0500) Subject: Use : to split assembly and resource X-Git-Tag: v0.2.4-beta~19 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=17bc0d18e9d71ff85353b1add2ddc74f2561bc09;p=jp%2Fvke.net.git Use : to split assembly and resource --- 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))