Final touches to FuncLoader
This commit is contained in:
parent
543a29569b
commit
a6d5693151
1 changed files with 7 additions and 3 deletions
|
@ -19,11 +19,12 @@ enum Library
|
||||||
class GLibrary
|
class GLibrary
|
||||||
{
|
{
|
||||||
private static Dictionary<Library, IntPtr> _libraries;
|
private static Dictionary<Library, IntPtr> _libraries;
|
||||||
|
private static Dictionary<string, IntPtr> _customlibraries;
|
||||||
private static List<(Library Library, string WindowsLib, string LinuxLib, string OSXLib)> _libdict;
|
private static List<(Library Library, string WindowsLib, string LinuxLib, string OSXLib)> _libdict;
|
||||||
private static IntPtr _temp = FuncLoader.LoadLibrary("libgtk-3.so.0");
|
|
||||||
|
|
||||||
static GLibrary()
|
static GLibrary()
|
||||||
{
|
{
|
||||||
|
_customlibraries = new Dictionary<string, IntPtr>();
|
||||||
_libraries = new Dictionary<Library, IntPtr>();
|
_libraries = new Dictionary<Library, IntPtr>();
|
||||||
_libdict = new List<(Library, string, string, string)>();
|
_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"));
|
_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)
|
if (index != -1)
|
||||||
return Load(_libdict[index].Library);
|
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)
|
public static IntPtr Load(Library library)
|
||||||
|
@ -60,7 +65,6 @@ class GLibrary
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
s = i.OSXLib;
|
s = i.OSXLib;
|
||||||
|
|
||||||
// Console.WriteLine(s);
|
|
||||||
_libraries[library] = ret = FuncLoader.LoadLibrary(s);
|
_libraries[library] = ret = FuncLoader.LoadLibrary(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue