From dae6f9d328f0e93c9f591e1adcc2f5d9e0740845 Mon Sep 17 00:00:00 2001 From: Archi Date: Sun, 23 Jan 2022 01:37:43 +0100 Subject: [PATCH] Use newer syntax for Enum.IsDefined() --- ArchiSteamFarm/Core/ASF.cs | 2 +- ArchiSteamFarm/Core/OS.cs | 2 +- ArchiSteamFarm/Helpers/ArchiCacheable.cs | 2 +- ArchiSteamFarm/Helpers/ArchiCryptoHelper.cs | 10 +- .../IPC/Controllers/Api/BotController.cs | 2 +- .../Api/TwoFactorAuthenticationController.cs | 2 +- ArchiSteamFarm/NLog/Logging.cs | 2 +- ArchiSteamFarm/Plugins/PluginsCore.cs | 2 +- ArchiSteamFarm/Steam/Bot.cs | 8 +- ArchiSteamFarm/Steam/Data/TradeOffer.cs | 2 +- ArchiSteamFarm/Steam/Data/UserPrivacy.cs | 12 +- .../Steam/Exchange/ParseTradeResult.cs | 2 +- .../Steam/Integration/ArchiHandler.cs | 2 +- .../Steam/Integration/ArchiWebHandler.cs | 12 +- ArchiSteamFarm/Steam/Interaction/Actions.cs | 4 +- ArchiSteamFarm/Steam/Interaction/Commands.cs | 190 +++++++++--------- ArchiSteamFarm/Steam/Security/Confirmation.cs | 2 +- .../Steam/Security/MobileAuthenticator.cs | 2 +- ArchiSteamFarm/Steam/Storage/BotConfig.cs | 16 +- ArchiSteamFarm/Storage/GlobalConfig.cs | 6 +- Directory.Build.props | 1 + Directory.Packages.props | 2 +- 22 files changed, 143 insertions(+), 142 deletions(-) diff --git a/ArchiSteamFarm/Core/ASF.cs b/ArchiSteamFarm/Core/ASF.cs index aa4789427..db498f8a9 100644 --- a/ArchiSteamFarm/Core/ASF.cs +++ b/ArchiSteamFarm/Core/ASF.cs @@ -96,7 +96,7 @@ public static class ASF { } internal static string GetFilePath(EFileType fileType) { - if (!Enum.IsDefined(typeof(EFileType), fileType)) { + if (!Enum.IsDefined(fileType)) { throw new InvalidEnumArgumentException(nameof(fileType), (int) fileType, typeof(EFileType)); } diff --git a/ArchiSteamFarm/Core/OS.cs b/ArchiSteamFarm/Core/OS.cs index 23d731ef3..d4286a2ce 100644 --- a/ArchiSteamFarm/Core/OS.cs +++ b/ArchiSteamFarm/Core/OS.cs @@ -121,7 +121,7 @@ internal static class OS { } internal static void Init(GlobalConfig.EOptimizationMode optimizationMode) { - if (!Enum.IsDefined(typeof(GlobalConfig.EOptimizationMode), optimizationMode)) { + if (!Enum.IsDefined(optimizationMode)) { throw new ArgumentNullException(nameof(optimizationMode)); } diff --git a/ArchiSteamFarm/Helpers/ArchiCacheable.cs b/ArchiSteamFarm/Helpers/ArchiCacheable.cs index 1a4fdbcd3..202b2a533 100644 --- a/ArchiSteamFarm/Helpers/ArchiCacheable.cs +++ b/ArchiSteamFarm/Helpers/ArchiCacheable.cs @@ -48,7 +48,7 @@ public sealed class ArchiCacheable : IDisposable { [PublicAPI] public async Task<(bool Success, T? Result)> GetValue(EFallback fallback = EFallback.DefaultForType) { - if (!Enum.IsDefined(typeof(EFallback), fallback)) { + if (!Enum.IsDefined(fallback)) { throw new InvalidEnumArgumentException(nameof(fallback), (int) fallback, typeof(EFallback)); } diff --git a/ArchiSteamFarm/Helpers/ArchiCryptoHelper.cs b/ArchiSteamFarm/Helpers/ArchiCryptoHelper.cs index ab9fa4207..182afffe1 100644 --- a/ArchiSteamFarm/Helpers/ArchiCryptoHelper.cs +++ b/ArchiSteamFarm/Helpers/ArchiCryptoHelper.cs @@ -60,7 +60,7 @@ public static class ArchiCryptoHelper { private static byte[] EncryptionKey = Encoding.UTF8.GetBytes(nameof(ArchiSteamFarm)); internal static async Task Decrypt(ECryptoMethod cryptoMethod, string encryptedString) { - if (!Enum.IsDefined(typeof(ECryptoMethod), cryptoMethod)) { + if (!Enum.IsDefined(cryptoMethod)) { throw new InvalidEnumArgumentException(nameof(cryptoMethod), (int) cryptoMethod, typeof(ECryptoMethod)); } @@ -79,7 +79,7 @@ public static class ArchiCryptoHelper { } internal static string? Encrypt(ECryptoMethod cryptoMethod, string decryptedString) { - if (!Enum.IsDefined(typeof(ECryptoMethod), cryptoMethod)) { + if (!Enum.IsDefined(cryptoMethod)) { throw new InvalidEnumArgumentException(nameof(cryptoMethod), (int) cryptoMethod, typeof(ECryptoMethod)); } @@ -98,7 +98,7 @@ public static class ArchiCryptoHelper { } internal static string Hash(EHashingMethod hashingMethod, string stringToHash) { - if (!Enum.IsDefined(typeof(EHashingMethod), hashingMethod)) { + if (!Enum.IsDefined(hashingMethod)) { throw new InvalidEnumArgumentException(nameof(hashingMethod), (int) hashingMethod, typeof(EHashingMethod)); } @@ -129,7 +129,7 @@ public static class ArchiCryptoHelper { throw new ArgumentOutOfRangeException(nameof(hashLength)); } - if (!Enum.IsDefined(typeof(EHashingMethod), hashingMethod)) { + if (!Enum.IsDefined(hashingMethod)) { throw new InvalidEnumArgumentException(nameof(hashingMethod), (int) hashingMethod, typeof(EHashingMethod)); } @@ -163,7 +163,7 @@ public static class ArchiCryptoHelper { throw new ArgumentNullException(nameof(salt)); } - if (!Enum.IsDefined(typeof(EHashingMethod), hashingMethod)) { + if (!Enum.IsDefined(hashingMethod)) { throw new InvalidEnumArgumentException(nameof(hashingMethod), (int) hashingMethod, typeof(EHashingMethod)); } diff --git a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs index 17903e253..04abb291b 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs @@ -261,7 +261,7 @@ public sealed class BotController : ArchiController { ArgumentNullException.ThrowIfNull(request); - if ((request.Type == ASF.EUserInputType.None) || !Enum.IsDefined(typeof(ASF.EUserInputType), request.Type) || string.IsNullOrEmpty(request.Value)) { + if ((request.Type == ASF.EUserInputType.None) || !Enum.IsDefined(request.Type) || string.IsNullOrEmpty(request.Value)) { return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, $"{nameof(request.Type)} || {nameof(request.Value)}"))); } diff --git a/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs b/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs index 4e2d65e95..6c4d65961 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs @@ -51,7 +51,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController { ArgumentNullException.ThrowIfNull(request); - if (request.AcceptedType.HasValue && ((request.AcceptedType.Value == Confirmation.EType.Unknown) || !Enum.IsDefined(typeof(Confirmation.EType), request.AcceptedType.Value))) { + if (request.AcceptedType.HasValue && ((request.AcceptedType.Value == Confirmation.EType.Unknown) || !Enum.IsDefined(request.AcceptedType.Value))) { return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(request.AcceptedType)))); } diff --git a/ArchiSteamFarm/NLog/Logging.cs b/ArchiSteamFarm/NLog/Logging.cs index 6a08ca334..3152a4ff5 100644 --- a/ArchiSteamFarm/NLog/Logging.cs +++ b/ArchiSteamFarm/NLog/Logging.cs @@ -73,7 +73,7 @@ internal static class Logging { } internal static async Task GetUserInput(ASF.EUserInputType userInputType, string botName = SharedInfo.ASF) { - if ((userInputType == ASF.EUserInputType.None) || !Enum.IsDefined(typeof(ASF.EUserInputType), userInputType)) { + if ((userInputType == ASF.EUserInputType.None) || !Enum.IsDefined(userInputType)) { throw new InvalidEnumArgumentException(nameof(userInputType), (int) userInputType, typeof(ASF.EUserInputType)); } diff --git a/ArchiSteamFarm/Plugins/PluginsCore.cs b/ArchiSteamFarm/Plugins/PluginsCore.cs index f00234083..25f7ebe4f 100644 --- a/ArchiSteamFarm/Plugins/PluginsCore.cs +++ b/ArchiSteamFarm/Plugins/PluginsCore.cs @@ -271,7 +271,7 @@ internal static class PluginsCore { internal static async Task OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0) { ArgumentNullException.ThrowIfNull(bot); - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } diff --git a/ArchiSteamFarm/Steam/Bot.cs b/ArchiSteamFarm/Steam/Bot.cs index 45edd685f..5d12cb85f 100644 --- a/ArchiSteamFarm/Steam/Bot.cs +++ b/ArchiSteamFarm/Steam/Bot.cs @@ -555,7 +555,7 @@ public sealed class Bot : IAsyncDisposable { throw new ArgumentNullException(nameof(botName)); } - if (!Enum.IsDefined(typeof(EFileType), fileType)) { + if (!Enum.IsDefined(fileType)) { throw new InvalidEnumArgumentException(nameof(fileType), (int) fileType, typeof(EFileType)); } @@ -575,7 +575,7 @@ public sealed class Bot : IAsyncDisposable { [PublicAPI] public string GetFilePath(EFileType fileType) { - if (!Enum.IsDefined(typeof(EFileType), fileType)) { + if (!Enum.IsDefined(fileType)) { throw new InvalidEnumArgumentException(nameof(fileType), (int) fileType, typeof(EFileType)); } @@ -764,7 +764,7 @@ public sealed class Bot : IAsyncDisposable { throw new ArgumentOutOfRangeException(nameof(steamID)); } - if ((access == BotConfig.EAccess.None) || !Enum.IsDefined(typeof(BotConfig.EAccess), access)) { + if ((access == BotConfig.EAccess.None) || !Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(BotConfig.EAccess)); } @@ -875,7 +875,7 @@ public sealed class Bot : IAsyncDisposable { [PublicAPI] public bool SetUserInput(ASF.EUserInputType inputType, string inputValue) { - if ((inputType == ASF.EUserInputType.None) || !Enum.IsDefined(typeof(ASF.EUserInputType), inputType)) { + if ((inputType == ASF.EUserInputType.None) || !Enum.IsDefined(inputType)) { throw new InvalidEnumArgumentException(nameof(inputType), (int) inputType, typeof(ASF.EUserInputType)); } diff --git a/ArchiSteamFarm/Steam/Data/TradeOffer.cs b/ArchiSteamFarm/Steam/Data/TradeOffer.cs index b89093d73..4a79f753f 100644 --- a/ArchiSteamFarm/Steam/Data/TradeOffer.cs +++ b/ArchiSteamFarm/Steam/Data/TradeOffer.cs @@ -58,7 +58,7 @@ public sealed class TradeOffer { throw new ArgumentOutOfRangeException(nameof(otherSteamID3)); } - if (!Enum.IsDefined(typeof(ETradeOfferState), state)) { + if (!Enum.IsDefined(state)) { throw new InvalidEnumArgumentException(nameof(state), (int) state, typeof(ETradeOfferState)); } diff --git a/ArchiSteamFarm/Steam/Data/UserPrivacy.cs b/ArchiSteamFarm/Steam/Data/UserPrivacy.cs index 7a17fb3f1..7af9356e1 100644 --- a/ArchiSteamFarm/Steam/Data/UserPrivacy.cs +++ b/ArchiSteamFarm/Steam/Data/UserPrivacy.cs @@ -65,27 +65,27 @@ internal sealed class UserPrivacy { // Constructed from privacy change request internal PrivacySettings(ArchiHandler.EPrivacySetting profile, ArchiHandler.EPrivacySetting ownedGames, ArchiHandler.EPrivacySetting playtime, ArchiHandler.EPrivacySetting friendsList, ArchiHandler.EPrivacySetting inventory, ArchiHandler.EPrivacySetting inventoryGifts) { - if ((profile == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(typeof(ArchiHandler.EPrivacySetting), profile)) { + if ((profile == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(profile)) { throw new InvalidEnumArgumentException(nameof(profile), (int) profile, typeof(ArchiHandler.EPrivacySetting)); } - if ((ownedGames == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(typeof(ArchiHandler.EPrivacySetting), ownedGames)) { + if ((ownedGames == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(ownedGames)) { throw new InvalidEnumArgumentException(nameof(ownedGames), (int) ownedGames, typeof(ArchiHandler.EPrivacySetting)); } - if ((playtime == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(typeof(ArchiHandler.EPrivacySetting), playtime)) { + if ((playtime == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(playtime)) { throw new InvalidEnumArgumentException(nameof(playtime), (int) playtime, typeof(ArchiHandler.EPrivacySetting)); } - if ((friendsList == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(typeof(ArchiHandler.EPrivacySetting), friendsList)) { + if ((friendsList == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(friendsList)) { throw new InvalidEnumArgumentException(nameof(friendsList), (int) friendsList, typeof(ArchiHandler.EPrivacySetting)); } - if ((inventory == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(typeof(ArchiHandler.EPrivacySetting), inventory)) { + if ((inventory == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(inventory)) { throw new InvalidEnumArgumentException(nameof(inventory), (int) inventory, typeof(ArchiHandler.EPrivacySetting)); } - if ((inventoryGifts == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(typeof(ArchiHandler.EPrivacySetting), inventoryGifts)) { + if ((inventoryGifts == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(inventoryGifts)) { throw new InvalidEnumArgumentException(nameof(inventoryGifts), (int) inventoryGifts, typeof(ArchiHandler.EPrivacySetting)); } diff --git a/ArchiSteamFarm/Steam/Exchange/ParseTradeResult.cs b/ArchiSteamFarm/Steam/Exchange/ParseTradeResult.cs index 610e6edd4..81e6de398 100644 --- a/ArchiSteamFarm/Steam/Exchange/ParseTradeResult.cs +++ b/ArchiSteamFarm/Steam/Exchange/ParseTradeResult.cs @@ -43,7 +43,7 @@ public sealed class ParseTradeResult { throw new ArgumentOutOfRangeException(nameof(tradeOfferID)); } - if ((result == EResult.Unknown) || !Enum.IsDefined(typeof(EResult), result)) { + if ((result == EResult.Unknown) || !Enum.IsDefined(result)) { throw new InvalidEnumArgumentException(nameof(result), (int) result, typeof(EResult)); } diff --git a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs index 5eec725be..c57d5d992 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs @@ -730,7 +730,7 @@ public sealed class ArchiHandler : ClientMsgHandler { } internal void SetCurrentMode(EUserInterfaceMode userInterfaceMode, byte chatMode = 2) { - if (!Enum.IsDefined(typeof(EUserInterfaceMode), userInterfaceMode)) { + if (!Enum.IsDefined(userInterfaceMode)) { throw new InvalidEnumArgumentException(nameof(userInterfaceMode), (int) userInterfaceMode, typeof(EUserInterfaceMode)); } diff --git a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs index 5c74b8c91..754429f68 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs @@ -727,7 +727,7 @@ public sealed class ArchiWebHandler : IDisposable { throw new ArgumentNullException(nameof(request)); } - if (!Enum.IsDefined(typeof(ESession), session)) { + if (!Enum.IsDefined(session)) { throw new InvalidEnumArgumentException(nameof(session), (int) session, typeof(ESession)); } @@ -841,7 +841,7 @@ public sealed class ArchiWebHandler : IDisposable { throw new ArgumentNullException(nameof(request)); } - if (!Enum.IsDefined(typeof(ESession), session)) { + if (!Enum.IsDefined(session)) { throw new InvalidEnumArgumentException(nameof(session), (int) session, typeof(ESession)); } @@ -955,7 +955,7 @@ public sealed class ArchiWebHandler : IDisposable { throw new ArgumentNullException(nameof(request)); } - if (!Enum.IsDefined(typeof(ESession), session)) { + if (!Enum.IsDefined(session)) { throw new InvalidEnumArgumentException(nameof(session), (int) session, typeof(ESession)); } @@ -1071,7 +1071,7 @@ public sealed class ArchiWebHandler : IDisposable { throw new ArgumentNullException(nameof(request)); } - if (!Enum.IsDefined(typeof(ESession), session)) { + if (!Enum.IsDefined(session)) { throw new InvalidEnumArgumentException(nameof(session), (int) session, typeof(ESession)); } @@ -1579,7 +1579,7 @@ public sealed class ArchiWebHandler : IDisposable { foreach (KeyValue trade in response["trade_offers_received"].Children) { ETradeOfferState state = trade["trade_offer_state"].AsEnum(); - if (!Enum.IsDefined(typeof(ETradeOfferState), state)) { + if (!Enum.IsDefined(state)) { Bot.ArchiLogger.LogNullError(nameof(state)); return null; @@ -2121,7 +2121,7 @@ public sealed class ArchiWebHandler : IDisposable { throw new ArgumentOutOfRangeException(nameof(steamID)); } - if ((universe == EUniverse.Invalid) || !Enum.IsDefined(typeof(EUniverse), universe)) { + if ((universe == EUniverse.Invalid) || !Enum.IsDefined(universe)) { throw new InvalidEnumArgumentException(nameof(universe), (int) universe, typeof(EUniverse)); } diff --git a/ArchiSteamFarm/Steam/Interaction/Actions.cs b/ArchiSteamFarm/Steam/Interaction/Actions.cs index 2eb562e7e..d44195950 100644 --- a/ArchiSteamFarm/Steam/Interaction/Actions.cs +++ b/ArchiSteamFarm/Steam/Interaction/Actions.cs @@ -70,7 +70,7 @@ public sealed class Actions : IAsyncDisposable { [PublicAPI] public static string? Encrypt(ArchiCryptoHelper.ECryptoMethod cryptoMethod, string stringToEncrypt) { - if (!Enum.IsDefined(typeof(ArchiCryptoHelper.ECryptoMethod), cryptoMethod)) { + if (!Enum.IsDefined(cryptoMethod)) { throw new InvalidEnumArgumentException(nameof(cryptoMethod), (int) cryptoMethod, typeof(ArchiCryptoHelper.ECryptoMethod)); } @@ -178,7 +178,7 @@ public sealed class Actions : IAsyncDisposable { [PublicAPI] public static string Hash(ArchiCryptoHelper.EHashingMethod hashingMethod, string stringToHash) { - if (!Enum.IsDefined(typeof(ArchiCryptoHelper.EHashingMethod), hashingMethod)) { + if (!Enum.IsDefined(hashingMethod)) { throw new InvalidEnumArgumentException(nameof(hashingMethod), (int) hashingMethod, typeof(ArchiCryptoHelper.EHashingMethod)); } diff --git a/ArchiSteamFarm/Steam/Interaction/Commands.cs b/ArchiSteamFarm/Steam/Interaction/Commands.cs index f11da1a1c..2ffe0878c 100644 --- a/ArchiSteamFarm/Steam/Interaction/Commands.cs +++ b/ArchiSteamFarm/Steam/Interaction/Commands.cs @@ -95,7 +95,7 @@ public sealed class Commands { [PublicAPI] public async Task Response(EAccess access, string message, ulong steamID = 0) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -517,7 +517,7 @@ public sealed class Commands { } private async Task Response2FA(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -531,7 +531,7 @@ public sealed class Commands { } private static async Task Response2FA(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -553,7 +553,7 @@ public sealed class Commands { } private async Task Response2FAConfirm(EAccess access, bool confirm) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -575,7 +575,7 @@ public sealed class Commands { } private static async Task Response2FAConfirm(EAccess access, string botNames, bool confirm) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -597,7 +597,7 @@ public sealed class Commands { } private async Task ResponseAddLicense(EAccess access, string query) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -669,7 +669,7 @@ public sealed class Commands { } private static async Task ResponseAddLicense(EAccess access, string botNames, string query) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -695,7 +695,7 @@ public sealed class Commands { } private async Task ResponseAdvancedLoot(EAccess access, string targetAppID, string targetContextID) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -729,7 +729,7 @@ public sealed class Commands { } private static async Task ResponseAdvancedLoot(EAccess access, string botNames, string appID, string contextID) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -759,7 +759,7 @@ public sealed class Commands { } private async Task ResponseAdvancedRedeem(EAccess access, string options, string keys, ulong steamID = 0) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -844,7 +844,7 @@ public sealed class Commands { } private static async Task ResponseAdvancedRedeem(EAccess access, string botNames, string options, string keys, ulong steamID = 0) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -874,7 +874,7 @@ public sealed class Commands { } private async Task ResponseAdvancedTransfer(EAccess access, uint appID, ulong contextID, Bot targetBot) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -906,7 +906,7 @@ public sealed class Commands { } private async Task ResponseAdvancedTransfer(EAccess access, string targetAppID, string targetContextID, string botNameTo) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -940,7 +940,7 @@ public sealed class Commands { } private static async Task ResponseAdvancedTransfer(EAccess access, string botNames, string targetAppID, string targetContextID, string botNameTo) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -988,7 +988,7 @@ public sealed class Commands { } private string? ResponseBackgroundGamesRedeemer(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1002,7 +1002,7 @@ public sealed class Commands { } private static async Task ResponseBackgroundGamesRedeemer(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1024,7 +1024,7 @@ public sealed class Commands { } private static string? ResponseEncrypt(EAccess access, string cryptoMethodText, string stringToEncrypt) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1050,7 +1050,7 @@ public sealed class Commands { } private static string? ResponseExit(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1064,7 +1064,7 @@ public sealed class Commands { } private async Task ResponseFarm(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1086,7 +1086,7 @@ public sealed class Commands { } private static async Task ResponseFarm(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1108,7 +1108,7 @@ public sealed class Commands { } private string? ResponseFarmingBlacklist(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1116,7 +1116,7 @@ public sealed class Commands { } private static async Task ResponseFarmingBlacklist(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1138,7 +1138,7 @@ public sealed class Commands { } private string? ResponseFarmingBlacklistAdd(EAccess access, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1183,7 +1183,7 @@ public sealed class Commands { } private static async Task ResponseFarmingBlacklistAdd(EAccess access, string botNames, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1209,7 +1209,7 @@ public sealed class Commands { } private string? ResponseFarmingBlacklistRemove(EAccess access, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1249,7 +1249,7 @@ public sealed class Commands { } private static async Task ResponseFarmingBlacklistRemove(EAccess access, string botNames, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1275,7 +1275,7 @@ public sealed class Commands { } private string? ResponseFarmingQueue(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1283,7 +1283,7 @@ public sealed class Commands { } private static async Task ResponseFarmingQueue(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1305,7 +1305,7 @@ public sealed class Commands { } private string? ResponseFarmingQueueAdd(EAccess access, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1357,7 +1357,7 @@ public sealed class Commands { } private static async Task ResponseFarmingQueueAdd(EAccess access, string botNames, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1383,7 +1383,7 @@ public sealed class Commands { } private string? ResponseFarmingQueueRemove(EAccess access, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1428,7 +1428,7 @@ public sealed class Commands { } private static async Task ResponseFarmingQueueRemove(EAccess access, string botNames, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1454,7 +1454,7 @@ public sealed class Commands { } private static string? ResponseHash(EAccess access, string hashingMethodText, string stringToHash) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1480,7 +1480,7 @@ public sealed class Commands { } private string? ResponseHelp(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1488,7 +1488,7 @@ public sealed class Commands { } private string? ResponseInput(EAccess access, string propertyName, string inputValue) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1510,7 +1510,7 @@ public sealed class Commands { return FormatBotResponse(Strings.ErrorFunctionOnlyInHeadlessMode); } - if (!Enum.TryParse(propertyName, true, out ASF.EUserInputType inputType) || (inputType == ASF.EUserInputType.None) || !Enum.IsDefined(typeof(ASF.EUserInputType), inputType)) { + if (!Enum.TryParse(propertyName, true, out ASF.EUserInputType inputType) || (inputType == ASF.EUserInputType.None) || !Enum.IsDefined(inputType)) { return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(inputType))); } @@ -1520,7 +1520,7 @@ public sealed class Commands { } private static async Task ResponseInput(EAccess access, string botNames, string propertyName, string inputValue) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1550,7 +1550,7 @@ public sealed class Commands { } private async Task ResponseLevel(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1568,7 +1568,7 @@ public sealed class Commands { } private static async Task ResponseLevel(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1590,7 +1590,7 @@ public sealed class Commands { } private async Task ResponseLoot(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1612,7 +1612,7 @@ public sealed class Commands { } private static async Task ResponseLoot(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1634,7 +1634,7 @@ public sealed class Commands { } private async Task ResponseLootByRealAppIDs(EAccess access, string realAppIDsText, bool exclude = false) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1676,7 +1676,7 @@ public sealed class Commands { } private static async Task ResponseLootByRealAppIDs(EAccess access, string botNames, string realAppIDsText, bool exclude = false) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1702,7 +1702,7 @@ public sealed class Commands { } private string? ResponseMatchActivelyBlacklist(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1710,7 +1710,7 @@ public sealed class Commands { } private static async Task ResponseMatchActivelyBlacklist(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1732,7 +1732,7 @@ public sealed class Commands { } private string? ResponseMatchActivelyBlacklistAdd(EAccess access, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1764,7 +1764,7 @@ public sealed class Commands { } private static async Task ResponseMatchActivelyBlacklistAdd(EAccess access, string botNames, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1790,7 +1790,7 @@ public sealed class Commands { } private string? ResponseMatchActivelyBlacklistRemove(EAccess access, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1822,7 +1822,7 @@ public sealed class Commands { } private static async Task ResponseMatchActivelyBlacklistRemove(EAccess access, string botNames, string targetAppIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1848,7 +1848,7 @@ public sealed class Commands { } private string? ResponseNickname(EAccess access, string nickname) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1870,7 +1870,7 @@ public sealed class Commands { } private static async Task ResponseNickname(EAccess access, string botNames, string nickname) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -1896,7 +1896,7 @@ public sealed class Commands { } private async Task<(string? Response, Dictionary? OwnedGames)> ResponseOwns(EAccess access, string query) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2048,7 +2048,7 @@ public sealed class Commands { } private static async Task ResponseOwns(EAccess access, string botNames, string query) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2096,7 +2096,7 @@ public sealed class Commands { } private async Task ResponsePause(EAccess access, bool permanent, string? resumeInSecondsText = null) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2120,7 +2120,7 @@ public sealed class Commands { } private static async Task ResponsePause(EAccess access, string botNames, bool permanent, string? resumeInSecondsText = null) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2142,7 +2142,7 @@ public sealed class Commands { } private async Task ResponsePlay(EAccess access, IReadOnlyCollection gameIDs, string? gameName = null) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2166,7 +2166,7 @@ public sealed class Commands { } private async Task ResponsePlay(EAccess access, string targetGameIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2213,7 +2213,7 @@ public sealed class Commands { } private static async Task ResponsePlay(EAccess access, string botNames, string targetGameIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2239,7 +2239,7 @@ public sealed class Commands { } private async Task ResponsePointsBalance(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2257,7 +2257,7 @@ public sealed class Commands { } private static async Task ResponsePointsBalance(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2279,7 +2279,7 @@ public sealed class Commands { } private async Task ResponsePrivacy(EAccess access, string privacySettingsText) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2317,7 +2317,7 @@ public sealed class Commands { // Converting digits to enum for (byte index = 0; index < privacySettingsArgs.Length; index++) { - if (!Enum.TryParse(privacySettingsArgs[index], true, out ArchiHandler.EPrivacySetting privacySetting) || (privacySetting == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(typeof(ArchiHandler.EPrivacySetting), privacySetting)) { + if (!Enum.TryParse(privacySettingsArgs[index], true, out ArchiHandler.EPrivacySetting privacySetting) || (privacySetting == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(privacySetting)) { return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(privacySettingsArgs))); } @@ -2413,7 +2413,7 @@ public sealed class Commands { } private static async Task ResponsePrivacy(EAccess access, string botNames, string privacySettingsText) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2439,7 +2439,7 @@ public sealed class Commands { } private async Task ResponseRedeem(EAccess access, string keysText, ulong steamID = 0, ERedeemFlags redeemFlags = ERedeemFlags.None) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2698,7 +2698,7 @@ public sealed class Commands { } private static async Task ResponseRedeem(EAccess access, string botNames, string keysText, ulong steamID = 0, ERedeemFlags redeemFlags = ERedeemFlags.None) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2724,7 +2724,7 @@ public sealed class Commands { } private async Task ResponseReset(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2742,7 +2742,7 @@ public sealed class Commands { } private static async Task ResponseReset(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2764,7 +2764,7 @@ public sealed class Commands { } private static string? ResponseRestart(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2778,7 +2778,7 @@ public sealed class Commands { } private string? ResponseResume(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2792,7 +2792,7 @@ public sealed class Commands { } private static async Task ResponseResume(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2814,7 +2814,7 @@ public sealed class Commands { } private string? ResponseStart(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2828,7 +2828,7 @@ public sealed class Commands { } private static async Task ResponseStart(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2850,7 +2850,7 @@ public sealed class Commands { } private string? ResponseStats(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2865,7 +2865,7 @@ public sealed class Commands { } private (string? Response, Bot Bot) ResponseStatus(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2907,7 +2907,7 @@ public sealed class Commands { } private static async Task ResponseStatus(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2937,7 +2937,7 @@ public sealed class Commands { } private string? ResponseStop(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2951,7 +2951,7 @@ public sealed class Commands { } private static async Task ResponseStop(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2973,7 +2973,7 @@ public sealed class Commands { } private string? ResponseTradingBlacklist(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -2981,7 +2981,7 @@ public sealed class Commands { } private static async Task ResponseTradingBlacklist(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3003,7 +3003,7 @@ public sealed class Commands { } private string? ResponseTradingBlacklistAdd(EAccess access, string targetSteamIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3035,7 +3035,7 @@ public sealed class Commands { } private static async Task ResponseTradingBlacklistAdd(EAccess access, string botNames, string targetSteamIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3061,7 +3061,7 @@ public sealed class Commands { } private string? ResponseTradingBlacklistRemove(EAccess access, string targetSteamIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3093,7 +3093,7 @@ public sealed class Commands { } private static async Task ResponseTradingBlacklistRemove(EAccess access, string botNames, string targetSteamIDs) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3119,7 +3119,7 @@ public sealed class Commands { } private async Task ResponseTransfer(EAccess access, string botNameTo) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3159,7 +3159,7 @@ public sealed class Commands { } private static async Task ResponseTransfer(EAccess access, string botNames, string botNameTo) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3185,7 +3185,7 @@ public sealed class Commands { } private async Task ResponseTransferByRealAppIDs(EAccess access, IReadOnlyCollection realAppIDs, Bot targetBot, bool exclude = false) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3221,7 +3221,7 @@ public sealed class Commands { } private async Task ResponseTransferByRealAppIDs(EAccess access, string realAppIDsText, string botNameTo, bool exclude = false) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3263,7 +3263,7 @@ public sealed class Commands { } private static async Task ResponseTransferByRealAppIDs(EAccess access, string botNames, string realAppIDsText, string botNameTo, bool exclude = false) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3315,7 +3315,7 @@ public sealed class Commands { } private string? ResponseUnknown(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3323,7 +3323,7 @@ public sealed class Commands { } private async Task ResponseUnpackBoosters(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3359,7 +3359,7 @@ public sealed class Commands { } private static async Task ResponseUnpackBoosters(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3381,7 +3381,7 @@ public sealed class Commands { } private static async Task ResponseUpdate(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3395,7 +3395,7 @@ public sealed class Commands { } private string? ResponseVersion(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3403,7 +3403,7 @@ public sealed class Commands { } private string? ResponseWalletBalance(EAccess access) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } @@ -3415,7 +3415,7 @@ public sealed class Commands { } private static async Task ResponseWalletBalance(EAccess access, string botNames) { - if (!Enum.IsDefined(typeof(EAccess), access)) { + if (!Enum.IsDefined(access)) { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } diff --git a/ArchiSteamFarm/Steam/Security/Confirmation.cs b/ArchiSteamFarm/Steam/Security/Confirmation.cs index a23ff941f..11de777ce 100644 --- a/ArchiSteamFarm/Steam/Security/Confirmation.cs +++ b/ArchiSteamFarm/Steam/Security/Confirmation.cs @@ -43,7 +43,7 @@ public sealed class Confirmation { ID = id > 0 ? id : throw new ArgumentOutOfRangeException(nameof(id)); Key = key > 0 ? key : throw new ArgumentOutOfRangeException(nameof(key)); Creator = creator > 0 ? creator : throw new ArgumentOutOfRangeException(nameof(creator)); - Type = Enum.IsDefined(typeof(EType), type) ? type : throw new InvalidEnumArgumentException(nameof(type), (int) type, typeof(EType)); + Type = Enum.IsDefined(type) ? type : throw new InvalidEnumArgumentException(nameof(type), (int) type, typeof(EType)); } // REF: Internal documentation diff --git a/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs b/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs index 27709b107..9487a64ce 100644 --- a/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs +++ b/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs @@ -182,7 +182,7 @@ public sealed class MobileAuthenticator : IDisposable { return null; } - if (!Enum.IsDefined(typeof(Confirmation.EType), type)) { + if (!Enum.IsDefined(type)) { Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(type), type)); return null; diff --git a/ArchiSteamFarm/Steam/Storage/BotConfig.cs b/ArchiSteamFarm/Steam/Storage/BotConfig.cs index d83e4d57e..68faa6b93 100644 --- a/ArchiSteamFarm/Steam/Storage/BotConfig.cs +++ b/ArchiSteamFarm/Steam/Storage/BotConfig.cs @@ -414,7 +414,7 @@ public sealed class BotConfig { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(BotBehaviour), BotBehaviour)); } - foreach (EFarmingOrder farmingOrder in FarmingOrders.Where(static farmingOrder => !Enum.IsDefined(typeof(EFarmingOrder), farmingOrder))) { + foreach (EFarmingOrder farmingOrder in FarmingOrders.Where(static farmingOrder => !Enum.IsDefined(farmingOrder))) { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(FarmingOrders), farmingOrder)); } @@ -426,14 +426,14 @@ public sealed class BotConfig { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(GamesPlayedWhileIdle), $"{nameof(GamesPlayedWhileIdle.Count)} {GamesPlayedWhileIdle.Count} > {ArchiHandler.MaxGamesPlayedConcurrently}")); } - foreach (Asset.EType lootableType in LootableTypes.Where(static lootableType => !Enum.IsDefined(typeof(Asset.EType), lootableType))) { + foreach (Asset.EType lootableType in LootableTypes.Where(static lootableType => !Enum.IsDefined(lootableType))) { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(LootableTypes), lootableType)); } HashSet? completeTypesToSendValidTypes = null; foreach (Asset.EType completableType in CompleteTypesToSend) { - if (!Enum.IsDefined(typeof(Asset.EType), completableType)) { + if (!Enum.IsDefined(completableType)) { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(CompleteTypesToSend), completableType)); } @@ -452,15 +452,15 @@ public sealed class BotConfig { } } - foreach (Asset.EType matchableType in MatchableTypes.Where(static matchableType => !Enum.IsDefined(typeof(Asset.EType), matchableType))) { + foreach (Asset.EType matchableType in MatchableTypes.Where(static matchableType => !Enum.IsDefined(matchableType))) { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(MatchableTypes), matchableType)); } - if (!Enum.IsDefined(typeof(EPersonaState), OnlineStatus)) { + if (!Enum.IsDefined(OnlineStatus)) { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(OnlineStatus), OnlineStatus)); } - if (!Enum.IsDefined(typeof(ArchiCryptoHelper.ECryptoMethod), PasswordFormat)) { + if (!Enum.IsDefined(PasswordFormat)) { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(PasswordFormat), PasswordFormat)); } @@ -485,7 +485,7 @@ public sealed class BotConfig { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(SteamUserPermissions), steamID)); } - if (!Enum.IsDefined(typeof(EAccess), permission)) { + if (!Enum.IsDefined(permission)) { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(SteamUserPermissions), permission)); } } @@ -494,7 +494,7 @@ public sealed class BotConfig { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(TradingPreferences), TradingPreferences)); } - return !Enum.IsDefined(typeof(ArchiHandler.EUserInterfaceMode), UserInterfaceMode) ? (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(UserInterfaceMode), UserInterfaceMode)) : (true, null); + return !Enum.IsDefined(UserInterfaceMode) ? (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(UserInterfaceMode), UserInterfaceMode)) : (true, null); } internal async Task GetDecryptedSteamPassword() { diff --git a/ArchiSteamFarm/Storage/GlobalConfig.cs b/ArchiSteamFarm/Storage/GlobalConfig.cs index 98a3c6d24..50b8cdc01 100644 --- a/ArchiSteamFarm/Storage/GlobalConfig.cs +++ b/ArchiSteamFarm/Storage/GlobalConfig.cs @@ -441,7 +441,7 @@ public sealed class GlobalConfig { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(FarmingDelay), FarmingDelay)); } - if (!Enum.IsDefined(typeof(ArchiCryptoHelper.EHashingMethod), IPCPasswordFormat)) { + if (!Enum.IsDefined(IPCPasswordFormat)) { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(IPCPasswordFormat), IPCPasswordFormat)); } @@ -449,7 +449,7 @@ public sealed class GlobalConfig { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(MaxFarmingTime), MaxFarmingTime)); } - if (!Enum.IsDefined(typeof(EOptimizationMode), OptimizationMode)) { + if (!Enum.IsDefined(OptimizationMode)) { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(OptimizationMode), OptimizationMode)); } @@ -465,7 +465,7 @@ public sealed class GlobalConfig { return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(SteamProtocols), SteamProtocols)); } - return Enum.IsDefined(typeof(EUpdateChannel), UpdateChannel) ? (true, null) : (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(UpdateChannel), UpdateChannel)); + return Enum.IsDefined(UpdateChannel) ? (true, null) : (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(UpdateChannel), UpdateChannel)); } internal static async Task<(GlobalConfig? GlobalConfig, string? LatestJson)> Load(string filePath) { diff --git a/Directory.Build.props b/Directory.Build.props index 54d9f45c1..a5d81c89c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -35,6 +35,7 @@ + diff --git a/Directory.Packages.props b/Directory.Packages.props index 602505e2e..e338b85a9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -27,7 +27,7 @@ - +