static NativeMethods() { _libraryFacade = Environment.Is64BitProcess ? new Native64BitLibraryFacade() : (INativeLibraryFacade) new Native32BitLibraryFacade(); Exception archSpecificException; _libraryVersion = GetVersionInfo(_libraryFacade, out archSpecificException); if (archSpecificException != null) { Exception fallbackException; var fallbackLibrary = new FallbackLibraryFacade(); _libraryVersion = GetVersionInfo(fallbackLibrary, out fallbackException); if (fallbackException != null) { throw archSpecificException; } _libraryFacade = fallbackLibrary; } }
internal static LightningVersionInfo Create(INativeLibraryFacade library) { if (library == null) throw new ArgumentNullException("library"); IntPtr minor, major, patch; var version = library.mdb_version(out major, out minor, out patch); return new LightningVersionInfo { Version = Marshal.PtrToStringAnsi(version), Major = major.ToInt32(), Minor = minor.ToInt32(), Patch = patch.ToInt32() }; }
internal static LightningVersionInfo Create(INativeLibraryFacade library) { if (library == null) { throw new ArgumentNullException("library"); } IntPtr minor, major, patch; var version = library.mdb_version(out major, out minor, out patch); return(new LightningVersionInfo { Version = Marshal.PtrToStringAnsi(version), Major = major.ToInt32(), Minor = minor.ToInt32(), Patch = patch.ToInt32() }); }
private static LightningVersionInfo GetVersionInfo(INativeLibraryFacade lib, out Exception exception) { exception = null; LightningVersionInfo versionInfo = null; try { versionInfo = LightningVersionInfo.Create(lib); } catch (DllNotFoundException dllNotFoundException) { exception = dllNotFoundException; } catch (BadImageFormatException badImageFormatException) { exception = badImageFormatException; } return versionInfo; }
private static LightningVersionInfo GetVersionInfo(INativeLibraryFacade lib, out Exception exception) { exception = null; LightningVersionInfo versionInfo = null; try { versionInfo = LightningVersionInfo.Create(lib); } catch (DllNotFoundException dllNotFoundException) { exception = dllNotFoundException; } catch (BadImageFormatException badImageFormatException) { exception = badImageFormatException; } return(versionInfo); }
static NativeMethods() { _libraryFacade = Environment.Is64BitProcess ? new Native64BitLibraryFacade() : (INativeLibraryFacade) new Native32BitLibraryFacade(); Exception archSpecificException; _libraryVersion = GetVersionInfo(_libraryFacade, out archSpecificException); if (archSpecificException != null) { Exception fallbackException; var fallbackLibrary = new FallbackLibraryFacade(); _libraryVersion = GetVersionInfo(fallbackLibrary, out fallbackException); if (fallbackException != null) throw archSpecificException; _libraryFacade = fallbackLibrary; } }