public string GetLibraryAbsolutePath(OperatingSystemPlatform currentPlatform) { var relativePath = GetLibraryDirectoryRelativePath(currentPlatform); var libraryName = GetLibraryName(currentPlatform); return(GetAbsolutePath(relativePath, libraryName)); }
static OsInfo() { var platform = Environment.OSVersion.Platform; switch (platform) { case PlatformID.Win32NT: { CurrentOS = OperatingSystemPlatform.Windows; break; } case PlatformID.MacOSX: case PlatformID.Unix: { // Sometimes Mac OS reports itself as Unix if (Directory.Exists("/System/Library/CoreServices/") && (File.Exists("/System/Library/CoreServices/SystemVersion.plist") || File.Exists("/System/Library/CoreServices/ServerVersion.plist"))) { CurrentOS = OperatingSystemPlatform.Osx; } else { CurrentOS = OperatingSystemPlatform.Linux; } break; } } }
public override string GetLibraryRelativePath(OperatingSystemPlatform currentPlatform) { switch (currentPlatform) { case OperatingSystemPlatform.Windows: return(@"runtimes\win\native\snappy32.dll"); case OperatingSystemPlatform.Linux: // TODO: add support for Linux and MacOS later case OperatingSystemPlatform.MacOS: default: throw new InvalidOperationException($"Snappy is not supported on the current platform: {currentPlatform}."); } }
private INativeLibraryLoader CreateNativeLoader(OperatingSystemPlatform currentPlatform, string libraryPath) { switch (currentPlatform) { case OperatingSystemPlatform.Linux: return(new LinuxLibraryLoader(libraryPath)); case OperatingSystemPlatform.MacOS: return(new DarwinLibraryLoader(libraryPath)); case OperatingSystemPlatform.Windows: return(new WindowsLibraryLoader(libraryPath)); default: throw new PlatformNotSupportedException($"Unexpected platform {currentPlatform}."); } }
public override int GetHashCode() { unchecked { var hashCode = FrameworkDescription != null?FrameworkDescription.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (RunningEnvironment != null ? RunningEnvironment.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (EntryAssemblyName != null ? EntryAssemblyName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (EntryAssemblyVersion != null ? EntryAssemblyVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (LocalTimeString != null ? LocalTimeString.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MachineName != null ? MachineName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OperatingSystemPlatform != null ? OperatingSystemPlatform.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OperatingSystemArchitecture != null ? OperatingSystemArchitecture.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OperatingSystemVersion != null ? OperatingSystemVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ProcessArchitecture != null ? ProcessArchitecture.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ProcessorCount != null ? ProcessorCount.GetHashCode() : 0); return(hashCode); } }
public override string GetLibraryName(OperatingSystemPlatform currentPlatform) => currentPlatform switch {
public abstract string GetLibraryRelativePath(OperatingSystemPlatform currentPlatform);
public string GetLibraryAbsolutePath(OperatingSystemPlatform currentPlatform) { var relativePath = GetLibraryRelativePath(currentPlatform); return(GetAbsolutePath(relativePath)); }
public virtual string GetCurrentPlatformRuntimeIdentifier(OperatingSystemPlatform currentPlatform) => currentPlatform switch {
public abstract string GetLibraryName(OperatingSystemPlatform currentPlatform);
public virtual string GetLibraryDirectoryRelativePath(OperatingSystemPlatform currentPlatform) { var rid = GetCurrentPlatformRuntimeIdentifier(currentPlatform); return(Path.Combine("runtimes", rid, "native")); }