예제 #1
0
        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()
            });
        }
예제 #4
0
        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;
        }
예제 #5
0
        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);
        }
예제 #6
0
        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;
            }
        }