Exemplo n.º 1
0
            protected override void Dispose(bool disposing)
            {
                if (_disposed)
                {
                    return;
                }
                _disposed = true;

                if (disposing)
                {
#if Mono
#else
                    if (_nativeLibraryManager != null)
                    {
                        try
                        {
                            _nativeLibraryManager.Dispose();
                        }
                        catch (Exception)
                        {
                        }

                        _nativeLibraryManager = null;
                    }
#endif
                }
            }
Exemplo n.º 2
0
            internal static void LoadNativeMethods()
            {
                _nativeLibraryManager?.Dispose();

                try
                {
                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                    {
                        if (Environment.Is64BitProcess)
                        {
                            _nativeLibraryManager = new NativeLibraryManager("Assemblies/Omnix.Correction.win-x64.dll");
                        }
                        else
                        {
                            throw new NotSupportedException();
                        }
                    }
                    else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                    {
                        if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
                        {
                            _nativeLibraryManager = new NativeLibraryManager("Assemblies/Omnix.Correction.linux-x64.so");
                        }
                        else
                        {
                            throw new NotSupportedException();
                        }
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }

                    _mul = _nativeLibraryManager.GetMethod<MulDelegate>("mul");
                }
                catch (Exception)
                {
                    _nativeLibraryManager?.Dispose();
                    _nativeLibraryManager = null;

                    throw;
                }
            }
Exemplo n.º 3
0
        internal static void LoadNativeMethods()
        {
            _nativeLibraryManager?.Dispose();

            try
            {
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
                    {
                        _nativeLibraryManager = new NativeLibraryManager("Assemblies/Omnix.Security.win-x64.dll");
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }
                }
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                {
                    if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
                    {
                        _nativeLibraryManager = new NativeLibraryManager("Assemblies/Omnix.Security.linux-x64.so");
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }

                _compute = _nativeLibraryManager.GetMethod <ComputeDelegate>("compute_Crc32_Castagnoli");
            }
            catch (Exception)
            {
                _nativeLibraryManager?.Dispose();
                _nativeLibraryManager = null;
            }
        }