public DetectedPlatformInfo(IDynLoader loader, string name, string cpuArch, string dllExtension) { Loader = loader; Name = name; CpuArch = cpuArch; DllExtension = dllExtension; }
public static T GetDllImport <T>(string name) { if (!_initialized) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _loader = new Win32Loader(); _library = _loader.LoadLibrary("libcairo-2.dll"); } else { _loader = new UnixLoader(); if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { _library = _loader.LoadLibrary("libcairo.2.dylib"); } else { _library = _loader.LoadLibrary("libcairo.so.2"); } } _initialized = true; } var dic = Holder <T> .Dictionary; T rv; if (!dic.TryGetValue(name, out rv)) { dic[name] = rv = Marshal.GetDelegateForFunctionPointer <T>(_loader.GetProcAddress(_library, name, false)); } return(rv); }
static IntPtr LoadDll(IDynLoader loader, GtkDll dll) { var exceptions = new List <Exception>(); var name = GetDllName(dll); if (Custom?.TrySystemFirst != false) { try { return(loader.LoadLibrary(name)); } catch (Exception e) { exceptions.Add(e); } } var path = Custom?.Lookup(dll); if (path == null && Custom?.BasePath != null) { path = Path.Combine(Custom.BasePath, name); } try { return(loader.LoadLibrary(path)); } catch (Exception e) { exceptions.Add(e); } throw new AggregateException("Unable to load " + dll, exceptions); }