static H5DLLImporter() { H5.open(); switch (Environment.OSVersion.Platform) { case PlatformID.Win32NT: case PlatformID.Win32S: case PlatformID.Win32Windows: case PlatformID.WinCE: Instance = new H5WindowsDLLImporter(Constants.DLLFileName); break; case PlatformID.Xbox: case PlatformID.MacOSX: Instance = new H5UnixDllImporter(Constants.DLLFileName); break; case PlatformID.Unix: // Instance = new H5WindowsDLLImporter(Constants.DLLFileName); Instance = new H5UnixDllImporter(Constants.DLLFileName); break; default: throw new NotImplementedException();; } }
static H5DLLImporter() { if (H5.open() < 0) { throw new Exception("Could not initialize HDF5 library."); } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Instance = new H5LinuxDllImporter(Constants.DLLFileName); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Instance = new H5MacDllImporter(Constants.DLLFileName); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Instance = new H5WindowsDLLImporter(Constants.DLLFileName); } else { throw new PlatformNotSupportedException(); } }
static H5DLLImporter() { // .NET Framework does not automatically load libraries from the native runtimes folder like .NET Core. // Therefore, if running .NET Framework, switch the current directory to the native runtime folder // before attempting to load the native HDF5 library. bool changedCurrentDir = false; var prevCurrentDir = Directory.GetCurrentDirectory(); if (RuntimeInformation.FrameworkDescription.Contains("Framework")) { var dllDir = Path.Combine(prevCurrentDir, string.Format(Constants.WindowsDLLPath, Environment.Is64BitProcess ? "64" : "86")); if (Directory.Exists(dllDir)) { Directory.SetCurrentDirectory(dllDir); changedCurrentDir = true; } } try { if (H5.open() < 0) { throw new Exception("Could not initialize HDF5 library."); } } finally { if (changedCurrentDir) { Directory.SetCurrentDirectory(prevCurrentDir); } } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Instance = new H5LinuxDllImporter(Constants.DLLFileName); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Instance = new H5MacDllImporter(Constants.DLLFileName); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Instance = new H5WindowsDLLImporter(Constants.DLLFileName); } else { throw new PlatformNotSupportedException(); } }
static H5E() { H5.open(); m_importer = H5DLLImporter.Create(); }