From a6d5693151cda5157bf3d0d38b446b8b371a12e5 Mon Sep 17 00:00:00 2001 From: cra0zy Date: Wed, 17 Jan 2018 22:58:11 +0100 Subject: [PATCH] Final touches to FuncLoader --- Source/Libs/Shared/FuncLoader.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/Libs/Shared/FuncLoader.cs b/Source/Libs/Shared/FuncLoader.cs index 0fc5c2847..ce52b55ac 100644 --- a/Source/Libs/Shared/FuncLoader.cs +++ b/Source/Libs/Shared/FuncLoader.cs @@ -19,11 +19,12 @@ enum Library class GLibrary { private static Dictionary _libraries; + private static Dictionary _customlibraries; private static List<(Library Library, string WindowsLib, string LinuxLib, string OSXLib)> _libdict; - private static IntPtr _temp = FuncLoader.LoadLibrary("libgtk-3.so.0"); static GLibrary() { + _customlibraries = new Dictionary(); _libraries = new Dictionary(); _libdict = new List<(Library, string, string, string)>(); _libdict.Add((Library.GLib, "libglib-2.0-0.dll", "libglib-2.0.so.0", "libglib-2.0.0.dylib")); @@ -44,7 +45,11 @@ class GLibrary if (index != -1) return Load(_libdict[index].Library); - return _temp; + var ret = IntPtr.Zero; + if (!_customlibraries.TryGetValue(libname, out ret)) + _customlibraries[libname] = ret = FuncLoader.LoadLibrary(libname); + + return ret; } public static IntPtr Load(Library library) @@ -60,7 +65,6 @@ class GLibrary else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) s = i.OSXLib; - // Console.WriteLine(s); _libraries[library] = ret = FuncLoader.LoadLibrary(s); }