Make use of latest Madness 1.1.0 features

This commit is contained in:
Archi
2021-08-10 17:09:46 +02:00
parent 350ef8c626
commit de0ee3a497
5 changed files with 6 additions and 53 deletions

View File

@@ -20,9 +20,9 @@
// limitations under the License.
#if NETFRAMEWORK
using System.Runtime.InteropServices;
using JustArchiNET.Madness;
using File = JustArchiNET.Madness.FileMadness.File;
using OperatingSystem = JustArchiNET.Madness.OperatingSystemMadness.OperatingSystem;
using Path = JustArchiNET.Madness.PathMadness.Path;
#endif
using System;
@@ -314,11 +314,7 @@ namespace ArchiSteamFarm.Core {
return null;
}
#if NETFRAMEWORK
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
#else
if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
#endif
string executable = Path.Combine(SharedInfo.HomeDirectory, SharedInfo.AssemblyName);
if (File.Exists(executable)) {

View File

@@ -21,6 +21,7 @@
#if NETFRAMEWORK
using JustArchiNET.Madness;
using OperatingSystem = JustArchiNET.Madness.OperatingSystemMadness.OperatingSystem;
#else
using System.Runtime.Versioning;
#endif
@@ -94,11 +95,7 @@ namespace ArchiSteamFarm.Core {
private static Mutex? SingleInstance;
internal static void CoreInit(bool systemRequired) {
#if NETFRAMEWORK
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
#else
if (OperatingSystem.IsWindows()) {
#endif
if (systemRequired) {
WindowsKeepSystemActive();
}
@@ -197,11 +194,7 @@ namespace ArchiSteamFarm.Core {
throw new ArgumentNullException(nameof(path));
}
#if NETFRAMEWORK
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
#else
if (!OperatingSystem.IsFreeBSD() && !OperatingSystem.IsLinux() && !OperatingSystem.IsMacOS()) {
#endif
throw new PlatformNotSupportedException();
}
@@ -238,7 +231,7 @@ namespace ArchiSteamFarm.Core {
}
// All windows variants have valid .NET Core build, and generic-netf is supported only on mono
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || !RuntimeMadness.IsRunningOnMono) {
if (OperatingSystem.IsWindows() || !RuntimeMadness.IsRunningOnMono) {
return false;
}
@@ -261,11 +254,7 @@ namespace ArchiSteamFarm.Core {
[SupportedOSPlatform("Windows")]
private static void WindowsDisableQuickEditMode() {
#if NETFRAMEWORK
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
#else
if (!OperatingSystem.IsWindows()) {
#endif
throw new PlatformNotSupportedException();
}
@@ -286,11 +275,7 @@ namespace ArchiSteamFarm.Core {
[SupportedOSPlatform("Windows")]
private static void WindowsKeepSystemActive() {
#if NETFRAMEWORK
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
#else
if (!OperatingSystem.IsWindows()) {
#endif
throw new PlatformNotSupportedException();
}

View File

@@ -20,7 +20,7 @@
// limitations under the License.
#if NETFRAMEWORK
using System.Runtime.InteropServices;
using OperatingSystem = JustArchiNET.Madness.OperatingSystemMadness.OperatingSystem;
#endif
using System;
using System.Collections.Generic;
@@ -189,11 +189,7 @@ namespace ArchiSteamFarm.Helpers {
throw new ArgumentNullException(nameof(encryptedString));
}
#if NETFRAMEWORK
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
#else
if (!OperatingSystem.IsWindows()) {
#endif
return null;
}
@@ -240,11 +236,7 @@ namespace ArchiSteamFarm.Helpers {
throw new ArgumentNullException(nameof(decryptedString));
}
#if NETFRAMEWORK
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
#else
if (!OperatingSystem.IsWindows()) {
#endif
return null;
}

View File

@@ -20,7 +20,7 @@
// limitations under the License.
#if NETFRAMEWORK
using System.Runtime.InteropServices;
using OperatingSystem = JustArchiNET.Madness.OperatingSystemMadness.OperatingSystem;
#endif
using System;
using System.Diagnostics;
@@ -165,11 +165,7 @@ namespace ArchiSteamFarm.Helpers {
if (!Directory.Exists(directoryPath)) {
Directory.CreateDirectory(directoryPath);
#if NETFRAMEWORK
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
#else
if (OperatingSystem.IsWindows()) {
#endif
DirectoryInfo directoryInfo = new(directoryPath);
try {
@@ -180,11 +176,7 @@ namespace ArchiSteamFarm.Helpers {
// Non-critical, user might have no rights to manage the resource
ASF.ArchiLogger.LogGenericDebuggingException(e);
}
#if NETFRAMEWORK
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
#else
} else if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
#endif
OS.UnixSetFileAccess(directoryPath, OS.EUnixPermission.Combined777);
}
}
@@ -192,11 +184,7 @@ namespace ArchiSteamFarm.Helpers {
try {
new FileStream(FilePath, FileMode.CreateNew).Dispose();
#if NETFRAMEWORK
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
#else
if (OperatingSystem.IsWindows()) {
#endif
FileInfo fileInfo = new(FilePath);
try {
@@ -207,11 +195,7 @@ namespace ArchiSteamFarm.Helpers {
// Non-critical, user might have no rights to manage the resource
ASF.ArchiLogger.LogGenericDebuggingException(e);
}
#if NETFRAMEWORK
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
#else
} else if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
#endif
OS.UnixSetFileAccess(FilePath, OS.EUnixPermission.Combined777);
}
} catch (IOException) {

View File

@@ -20,7 +20,7 @@
// limitations under the License.
#if NETFRAMEWORK
using System.Runtime.InteropServices;
using OperatingSystem = JustArchiNET.Madness.OperatingSystemMadness.OperatingSystem;
#endif
using System;
using System.Collections;
@@ -274,11 +274,7 @@ namespace ArchiSteamFarm {
// April Fools easter egg logic
AprilFools.Init();
#if NETFRAMEWORK
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
#else
if (OperatingSystem.IsWindows()) {
#endif
SystemEvents.TimeChanged += AprilFools.OnTimeChanged;
}
}