static private Decrypt ( ECryptoMethod cryptoMethod, string encrypted ) : string | ||
cryptoMethod | ECryptoMethod | |
encrypted | string | |
return | string |
internal static BotConfig Load(string filePath) { if (string.IsNullOrEmpty(filePath)) { ASF.ArchiLogger.LogNullError(nameof(filePath)); return(null); } if (!File.Exists(filePath)) { return(null); } BotConfig botConfig; try { botConfig = JsonConvert.DeserializeObject <BotConfig>(File.ReadAllText(filePath)); } catch (Exception e) { ASF.ArchiLogger.LogGenericException(e); return(null); } if (botConfig == null) { ASF.ArchiLogger.LogNullError(nameof(botConfig)); return(null); } botConfig.ShouldSerializeSensitiveDetails = false; // Support encrypted passwords if ((botConfig.PasswordFormat != CryptoHelper.ECryptoMethod.PlainText) && !string.IsNullOrEmpty(botConfig.SteamPassword)) { // In worst case password will result in null, which will have to be corrected by user during runtime botConfig.SteamPassword = CryptoHelper.Decrypt(botConfig.PasswordFormat, botConfig.SteamPassword); } // User might not know what he's doing // Ensure that he can't screw core ASF variables if (botConfig.GamesPlayedWhileIdle.Count <= ArchiHandler.MaxGamesPlayedConcurrently) { return(botConfig); } ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningTooManyGamesToPlay, ArchiHandler.MaxGamesPlayedConcurrently, nameof(botConfig.GamesPlayedWhileIdle))); HashSet <uint> validGames = new HashSet <uint>(botConfig.GamesPlayedWhileIdle.Take(ArchiHandler.MaxGamesPlayedConcurrently)); botConfig.GamesPlayedWhileIdle.IntersectWith(validGames); botConfig.GamesPlayedWhileIdle.TrimExcess(); return(botConfig); }
internal static BotConfig Load(string filePath) { if (string.IsNullOrEmpty(filePath)) { Logging.LogNullError(nameof(filePath)); return(null); } if (!File.Exists(filePath)) { return(null); } BotConfig botConfig; try { botConfig = JsonConvert.DeserializeObject <BotConfig>(File.ReadAllText(filePath)); } catch (Exception e) { Logging.LogGenericException(e); return(null); } if (botConfig == null) { Logging.LogNullError(nameof(botConfig)); return(null); } // Support encrypted passwords if ((botConfig.PasswordFormat != CryptoHelper.ECryptoMethod.PlainText) && !string.IsNullOrEmpty(botConfig.SteamPassword)) { // In worst case password will result in null, which will have to be corrected by user during runtime botConfig.SteamPassword = CryptoHelper.Decrypt(botConfig.PasswordFormat, botConfig.SteamPassword); } // User might not know what he's doing // Ensure that he can't screw core ASF variables if (botConfig.GamesPlayedWhileIdle.Count <= CardsFarmer.MaxGamesPlayedConcurrently) { return(botConfig); } Logging.LogGenericWarning("Playing more than " + CardsFarmer.MaxGamesPlayedConcurrently + " games concurrently is not possible, only first " + CardsFarmer.MaxGamesPlayedConcurrently + " entries from GamesPlayedWhileIdle will be used"); HashSet <uint> validGames = new HashSet <uint>(botConfig.GamesPlayedWhileIdle.Take(CardsFarmer.MaxGamesPlayedConcurrently)); botConfig.GamesPlayedWhileIdle.IntersectWith(validGames); botConfig.GamesPlayedWhileIdle.TrimExcess(); return(botConfig); }