Example #1
0
        private IntPtr LoadWithResolver(string name, PathResolver pathResolver)
        {
            if (Path.IsPathRooted(name))
            {
                return(CoreLoadNativeLibrary(name));
            }
            else
            {
                foreach (string loadTarget in pathResolver.EnumeratePossibleLibraryLoadTargets(name))
                {
                    if (!Path.IsPathRooted(loadTarget) || File.Exists(loadTarget))
                    {
                        IntPtr ret = CoreLoadNativeLibrary(loadTarget);
                        if (ret != IntPtr.Zero)
                        {
                            return(ret);
                        }
                    }
                }

                return(IntPtr.Zero);
            }
        }
Example #2
0
 /// <summary>
 /// Constructs a new NativeLibrary using the specified library loader.
 /// </summary>
 /// <param name="names">An ordered list of names to attempt to load.</param>
 /// <param name="loader">The loader used to open and close the library, and to load function pointers.</param>
 /// <param name="pathResolver">The path resolver, used to identify possible load targets for the library.</param>
 public NativeLibrary(string[] names, LibraryLoader loader, PathResolver pathResolver)
 {
     _loader = loader;
     Handle  = _loader.LoadNativeLibrary(names, pathResolver);
 }