コード例 #1
0
        /// <summary>
        ///     Loads library in a platform specific way.
        /// </summary>
        static IntPtr PlatformSpecificLoadLibrary(string libraryPath)
        {
            if (IsWindows)
            {
                return(Windows.LoadLibrary(libraryPath));
            }
            if (IsLinux)
            {
                if (IsMono)
                {
                    return(Mono.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY));
                }
                if (IsNetCore)
                {
                    return(CoreCLR.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY));
                }
                return(Linux.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY));
            }

            if (IsMacOSPlatform)
            {
                return(MacOSX.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY));
            }
            throw new InvalidOperationException("Unsupported platform.");
        }
コード例 #2
0
 public static IntPtr LoadLibrary(string libname)
 {
     if (IsWindows)
     {
         return(Windows.LoadLibraryW(libname));
     }
     return(IsOSX ? OSX.dlopen(libname, 1) : Linux.dlopen(libname, 1));
 }
コード例 #3
0
ファイル: Util.cs プロジェクト: italodirenzo93/sdl2net
 internal static IntPtr LoadLibrary(string name)
 {
     return(CurrentPlatform switch
     {
         Platform.Windows => Windows.LoadLibraryW(name),
         Platform.Linux => Linux.dlopen(name, RTLD_LAZY),
         Platform.MacOS => MacOS.dlopen(name, RTLD_LAZY),
         _ => throw new NotSupportedException(RuntimeInformation.OSDescription)
     });
コード例 #4
0
        public static IntPtr LoadLibrary(string libname)
        {
            if (CurrentPlatform.OS == OS.Windows)
            {
                return(Windows.LoadLibraryW(libname));
            }

            if (CurrentPlatform.OS == OS.MacOSX)
            {
                return(OSX.dlopen(libname, RTLD_GLOBAL | RTLD_LAZY));
            }

            return(Linux.dlopen(libname, RTLD_GLOBAL | RTLD_LAZY));
        }
コード例 #5
0
        public static IntPtr LoadLibrary(string libname)
        {
            if (IsWindows)
            {
                return(Windows.LoadLibraryW(libname));
            }

            if (IsOSX)
            {
                return(OSX.dlopen(libname, RTLD_GLOBAL | RTLD_LAZY));
            }

            return(Linux.dlopen(libname, RTLD_GLOBAL | RTLD_LAZY));
        }
コード例 #6
0
        public static IntPtr LoadLibrary(string libname)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return(Windows.LoadLibraryW(libname));
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                return(OSX.dlopen(libname, RTLD_LAZY));
            }

            return(Linux.dlopen(libname, RTLD_LAZY));
        }
コード例 #7
0
        public static IntPtr LoadLibrary(string libname)
        {
            if (Environment.OSVersion.IsWindows())
            {
                return(Windows.LoadLibraryW(libname));
            }

            if (Environment.OSVersion.IsMacOSX())
            {
                return(OSX.dlopen(libname, RTLD_LAZY));
            }

            return(Linux.dlopen(libname, RTLD_LAZY));
        }
コード例 #8
0
        public static IntPtr LoadLibrary(string libname)
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                return(Windows.LoadLibraryW(libname));
            }

            if (Environment.OSVersion.Platform == PlatformID.MacOSX)
            {
                return(OSX.dlopen(libname, RTLD_LAZY));
            }

            return(Linux.dlopen(libname, RTLD_LAZY));
        }
コード例 #9
0
 /// <summary>
 /// Loads library in a platform specific way.
 /// </summary>
 private static IntPtr PlatformSpecificLoadLibrary(string libraryPath)
 {
     if (PlatformApis.IsWindows)
     {
         return(Windows.LoadLibrary(libraryPath));
     }
     if (PlatformApis.IsLinux)
     {
         return(Linux.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY));
     }
     if (PlatformApis.IsMacOSX)
     {
         return(MacOSX.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY));
     }
     throw new InvalidOperationException("Unsupported platform.");
 }
コード例 #10
0
        static NativeLibrary()
        {
            const int RTLD_NOW = 2;

            if (Platform.IsWindows)
            {
                Open      = Windows.LoadLibrary;
                GetSymbol = Windows.GetProcAddress;
            }
            else if (Platform.IsOSX)
            {
                Open      = f => OSX.dlopen(f, RTLD_NOW);
                GetSymbol = OSX.dlsym;
            }
            else if (Platform.IsLinux)
            {
                if (Platform.IsMono)
                {
                    Open      = f => Mono.dlopen(f, RTLD_NOW);
                    GetSymbol = Mono.dlsym;
                }
                else if (Platform.IsNetCore)
                {
                    Open      = f => CoreCLR.dlopen(f, RTLD_NOW);
                    GetSymbol = CoreCLR.dlsym;
                }
                else
                {
                    Open      = f => Linux.dlopen(f, RTLD_NOW);
                    GetSymbol = Linux.dlsym;
                }
            }
            else
            {
                throw new PlatformNotSupportedException();
            }
        }
コード例 #11
0
 private static IntPtr LoadLibrary(string libName)
 {
     return(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
         ? Windows.LoadLibraryW(libName)
         : Linux.dlopen(libName, RtldLazy));
 }