static UnsafeNativeMethods()
        {
            PlatformDlls libraryInfo = GetNativeLibraryInfo();
            var          path        = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            foreach (var dll in libraryInfo.DllNames)
            {
                var dllPath = Path.Combine(path, "Native", libraryInfo.Path, dll);
                NativeLibrary.Load(dllPath);
            }
        }
        private static PlatformDlls GetNativeLibraryInfo()
        {
            PlatformDlls platformDlls = new PlatformDlls();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
                (RuntimeInformation.ProcessArchitecture == Architecture.X64))
            {
                platformDlls.Path     = "Win64";
                platformDlls.DllNames = new[] {
                    "icudt50.dll",
                    "icuin50.dll",
                    "icuuc50.dll",
                    "libicudecnumber.dll",
                    "libsapucum.dll",
                    "sapnwrfc.dll"
                };
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
                     (RuntimeInformation.ProcessArchitecture == Architecture.X86))
            {
                platformDlls.Path     = "Win32";
                platformDlls.DllNames = new[] {
                    "icudt50.dll",
                    "icuin50.dll",
                    "icuuc50.dll",
                    "libicudecnumber.dll",
                    "libsapucum.dll",
                    "sapnwrfc.dll"
                };
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) &&
                     (RuntimeInformation.ProcessArchitecture == Architecture.X64))
            {
                platformDlls.Path     = "Linux64";
                platformDlls.DllNames = new[]
                {
                    "libicudata.so.50",
                    "libicudecnumber.so",
                    "libicui18n.so.50",
                    "libicuuc.so.50",
                    "libsapnwrfc.so",
                    "libsapucum.so"
                };
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                platformDlls.Path     = "OSX";
                platformDlls.DllNames = new[] {
                    "libicudata.50.dylib",
                    "libicudecnumber.dylib",
                    "libicui18n.50.dylib",
                    "libicuuc.50.dylib",
                    "libsapnwrfc.dylib",
                    "libsapucum.dylib"
                };
            }
            else
            {
                throw new Exception("Unsupported OSPlatform, can't locate sapnwrfc library.");
            }

            return(platformDlls);
        }