mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-20 16:28:38 +00:00
C# 7.0 syntax sugars
This commit is contained in:
@@ -41,13 +41,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
internal DateTime LastPacketReceived { get; private set; } = DateTime.MinValue;
|
||||
|
||||
internal ArchiHandler(ArchiLogger archiLogger) {
|
||||
if (archiLogger == null) {
|
||||
throw new ArgumentNullException(nameof(archiLogger));
|
||||
}
|
||||
|
||||
ArchiLogger = archiLogger;
|
||||
}
|
||||
internal ArchiHandler(ArchiLogger archiLogger) => ArchiLogger = archiLogger ?? throw new ArgumentNullException(nameof(archiLogger));
|
||||
|
||||
public override void HandleMsg(IPacketMsg packetMsg) {
|
||||
if (packetMsg == null) {
|
||||
|
||||
@@ -69,12 +69,7 @@ namespace ArchiSteamFarm {
|
||||
private ulong SteamID;
|
||||
|
||||
internal ArchiWebHandler(Bot bot) {
|
||||
if (bot == null) {
|
||||
throw new ArgumentNullException(nameof(bot));
|
||||
}
|
||||
|
||||
Bot = bot;
|
||||
|
||||
Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
||||
WebBrowser = new WebBrowser(bot.ArchiLogger);
|
||||
}
|
||||
|
||||
@@ -417,8 +412,7 @@ namespace ArchiSteamFarm {
|
||||
return null;
|
||||
}
|
||||
|
||||
uint steamID3;
|
||||
if (!uint.TryParse(miniProfile, out steamID3) || (steamID3 == 0)) {
|
||||
if (!uint.TryParse(miniProfile, out uint steamID3) || (steamID3 == 0)) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(steamID3));
|
||||
return null;
|
||||
}
|
||||
@@ -466,8 +460,7 @@ namespace ArchiSteamFarm {
|
||||
return null;
|
||||
}
|
||||
|
||||
uint appID;
|
||||
if (!uint.TryParse(appNode.InnerText, out appID)) {
|
||||
if (!uint.TryParse(appNode.InnerText, out uint appID)) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(appID));
|
||||
return null;
|
||||
}
|
||||
@@ -515,8 +508,7 @@ namespace ArchiSteamFarm {
|
||||
continue;
|
||||
}
|
||||
|
||||
ulong classID;
|
||||
if (!ulong.TryParse(classIDString, out classID) || (classID == 0)) {
|
||||
if (!ulong.TryParse(classIDString, out ulong classID) || (classID == 0)) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(classID));
|
||||
continue;
|
||||
}
|
||||
@@ -579,8 +571,7 @@ namespace ArchiSteamFarm {
|
||||
steamItem.AppID = Steam.Item.SteamAppID;
|
||||
steamItem.ContextID = Steam.Item.SteamCommunityContextID;
|
||||
|
||||
Tuple<uint, Steam.Item.EType> description;
|
||||
if (descriptionMap.TryGetValue(steamItem.ClassID, out description)) {
|
||||
if (descriptionMap.TryGetValue(steamItem.ClassID, out Tuple<uint, Steam.Item.EType> description)) {
|
||||
steamItem.RealAppID = description.Item1;
|
||||
steamItem.Type = description.Item2;
|
||||
}
|
||||
@@ -592,13 +583,11 @@ namespace ArchiSteamFarm {
|
||||
result.Add(steamItem);
|
||||
}
|
||||
|
||||
bool more;
|
||||
if (!bool.TryParse(jObject["more"]?.ToString(), out more) || !more) {
|
||||
if (!bool.TryParse(jObject["more"]?.ToString(), out bool more) || !more) {
|
||||
break; // OK, last page
|
||||
}
|
||||
|
||||
uint nextPage;
|
||||
if (!uint.TryParse(jObject["more_start"]?.ToString(), out nextPage) || (nextPage <= currentPage)) {
|
||||
if (!uint.TryParse(jObject["more_start"]?.ToString(), out uint nextPage) || (nextPage <= currentPage)) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(nextPage));
|
||||
return null;
|
||||
}
|
||||
@@ -738,8 +727,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
text = text.Substring(0, index);
|
||||
|
||||
byte holdDuration;
|
||||
if (byte.TryParse(text, out holdDuration)) {
|
||||
if (byte.TryParse(text, out byte holdDuration)) {
|
||||
return holdDuration;
|
||||
}
|
||||
|
||||
@@ -1193,8 +1181,7 @@ namespace ArchiSteamFarm {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint appID;
|
||||
return uint.TryParse(hashName.Substring(0, index), out appID) ? appID : 0;
|
||||
return uint.TryParse(hashName.Substring(0, index), out uint appID) ? appID : 0;
|
||||
}
|
||||
|
||||
private static Steam.Item.EType GetItemType(string name) {
|
||||
@@ -1287,8 +1274,7 @@ namespace ArchiSteamFarm {
|
||||
uint realAppID = appID;
|
||||
Steam.Item.EType type = Steam.Item.EType.Unknown;
|
||||
|
||||
Tuple<uint, Steam.Item.EType> description;
|
||||
if (descriptions.TryGetValue(classID, out description)) {
|
||||
if (descriptions.TryGetValue(classID, out Tuple<uint, Steam.Item.EType> description)) {
|
||||
realAppID = description.Item1;
|
||||
type = description.Item2;
|
||||
}
|
||||
|
||||
@@ -347,8 +347,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
foreach (Dictionary<uint, SteamApps.PICSProductInfoCallback.PICSProductInfo> productInfoApps in productInfoResultSet.Results.Select(result => result.Apps)) {
|
||||
SteamApps.PICSProductInfoCallback.PICSProductInfo productInfoApp;
|
||||
if (!productInfoApps.TryGetValue(appID, out productInfoApp)) {
|
||||
if (!productInfoApps.TryGetValue(appID, out SteamApps.PICSProductInfoCallback.PICSProductInfo productInfoApp)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -418,8 +417,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
string[] dlcAppIDsString = listOfDlc.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string dlcAppIDString in dlcAppIDsString) {
|
||||
uint dlcAppID;
|
||||
if (!uint.TryParse(dlcAppIDString, out dlcAppID) || (dlcAppID == 0)) {
|
||||
if (!uint.TryParse(dlcAppIDString, out uint dlcAppID) || (dlcAppID == 0)) {
|
||||
ArchiLogger.LogNullError(nameof(dlcAppID));
|
||||
break;
|
||||
}
|
||||
@@ -784,8 +782,7 @@ namespace ArchiSteamFarm {
|
||||
Task.Run(() => Stop()).Forget();
|
||||
}
|
||||
|
||||
Bot ignored;
|
||||
Bots.TryRemove(BotName, out ignored);
|
||||
Bots.TryRemove(BotName, out Bot ignored);
|
||||
}
|
||||
|
||||
private void Disconnect() {
|
||||
@@ -832,8 +829,7 @@ namespace ArchiSteamFarm {
|
||||
if (botName.Contains("..")) {
|
||||
string[] botRange = botName.Split(new[] { ".." }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (botRange.Length == 2) {
|
||||
Bot firstBot, lastBot;
|
||||
if (Bots.TryGetValue(botRange[0], out firstBot) && Bots.TryGetValue(botRange[1], out lastBot)) {
|
||||
if (Bots.TryGetValue(botRange[0], out Bot firstBot) && Bots.TryGetValue(botRange[1], out Bot lastBot)) {
|
||||
bool inRange = false;
|
||||
|
||||
foreach (Bot bot in Bots.OrderBy(bot => bot.Key).Select(bot => bot.Value)) {
|
||||
@@ -855,8 +851,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
Bot targetBot;
|
||||
if (!Bots.TryGetValue(botName, out targetBot)) {
|
||||
if (!Bots.TryGetValue(botName, out Bot targetBot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1947,8 +1942,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
HashSet<uint> gamesToRedeem = new HashSet<uint>();
|
||||
foreach (string game in gameIDs) {
|
||||
uint gameID;
|
||||
if (!uint.TryParse(game, out gameID) || (gameID == 0)) {
|
||||
if (!uint.TryParse(game, out uint gameID) || (gameID == 0)) {
|
||||
return FormatBotResponse(string.Format(Strings.ErrorParsingObject, nameof(gameID)));
|
||||
}
|
||||
|
||||
@@ -2108,8 +2102,7 @@ namespace ArchiSteamFarm {
|
||||
return FormatBotResponse(Strings.ErrorFunctionOnlyInHeadlessMode);
|
||||
}
|
||||
|
||||
ASF.EUserInputType inputType;
|
||||
if (!Enum.TryParse(propertyName, true, out inputType) || (inputType == ASF.EUserInputType.Unknown)) {
|
||||
if (!Enum.TryParse(propertyName, true, out ASF.EUserInputType inputType) || (inputType == ASF.EUserInputType.Unknown)) {
|
||||
return FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(inputType)));
|
||||
}
|
||||
|
||||
@@ -2310,15 +2303,13 @@ namespace ArchiSteamFarm {
|
||||
|
||||
foreach (string game in games) {
|
||||
// Check if this is gameID
|
||||
uint gameID;
|
||||
if (uint.TryParse(game, out gameID) && (gameID != 0)) {
|
||||
if (uint.TryParse(game, out uint gameID) && (gameID != 0)) {
|
||||
if (OwnedPackageIDs.Contains(gameID)) {
|
||||
response.Append(FormatBotResponse(string.Format(Strings.BotOwnedAlready, gameID)));
|
||||
continue;
|
||||
}
|
||||
|
||||
string ownedName;
|
||||
response.Append(FormatBotResponse(ownedGames.TryGetValue(gameID, out ownedName) ? string.Format(Strings.BotOwnedAlreadyWithName, gameID, ownedName) : string.Format(Strings.BotNotOwnedYet, gameID)));
|
||||
response.Append(FormatBotResponse(ownedGames.TryGetValue(gameID, out string ownedName) ? string.Format(Strings.BotOwnedAlreadyWithName, gameID, ownedName) : string.Format(Strings.BotNotOwnedYet, gameID)));
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -2509,8 +2500,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
HashSet<uint> gamesToPlay = new HashSet<uint>();
|
||||
foreach (string game in gameIDs) {
|
||||
uint gameID;
|
||||
if (!uint.TryParse(game, out gameID)) {
|
||||
if (!uint.TryParse(game, out uint gameID)) {
|
||||
return FormatBotResponse(string.Format(Strings.ErrorParsingObject, nameof(gameID)));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace ArchiSteamFarm {
|
||||
private readonly object FileLock = new object();
|
||||
|
||||
internal string LoginKey {
|
||||
get { return _LoginKey; }
|
||||
get => _LoginKey;
|
||||
|
||||
set {
|
||||
if (_LoginKey == value) {
|
||||
@@ -46,7 +46,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal MobileAuthenticator MobileAuthenticator {
|
||||
get { return _MobileAuthenticator; }
|
||||
get => _MobileAuthenticator;
|
||||
|
||||
set {
|
||||
if (_MobileAuthenticator == value) {
|
||||
|
||||
@@ -69,11 +69,7 @@ namespace ArchiSteamFarm {
|
||||
private bool StickyPause;
|
||||
|
||||
internal CardsFarmer(Bot bot) {
|
||||
if (bot == null) {
|
||||
throw new ArgumentNullException(nameof(bot));
|
||||
}
|
||||
|
||||
Bot = bot;
|
||||
Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
||||
|
||||
if (Program.GlobalConfig.IdleFarmingPeriod > 0) {
|
||||
IdleFarmingTimer = new Timer(
|
||||
@@ -340,8 +336,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
appIDString = appIDSplitted[4];
|
||||
|
||||
uint appID;
|
||||
if (!uint.TryParse(appIDString, out appID) || (appID == 0)) {
|
||||
if (!uint.TryParse(appIDString, out uint appID) || (appID == 0)) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(appID));
|
||||
continue;
|
||||
}
|
||||
@@ -351,8 +346,7 @@ namespace ArchiSteamFarm {
|
||||
continue;
|
||||
}
|
||||
|
||||
DateTime lastPICSReport;
|
||||
if (IgnoredAppIDs.TryGetValue(appID, out lastPICSReport)) {
|
||||
if (IgnoredAppIDs.TryGetValue(appID, out DateTime lastPICSReport)) {
|
||||
if (lastPICSReport.AddHours(HoursToIgnore) < DateTime.UtcNow) {
|
||||
// This game served its time as being ignored
|
||||
IgnoredAppIDs.TryRemove(appID, out lastPICSReport);
|
||||
@@ -409,8 +403,7 @@ namespace ArchiSteamFarm {
|
||||
continue;
|
||||
}
|
||||
|
||||
ushort cardsEarned;
|
||||
if (!ushort.TryParse(cardsEarnedMatch.Value, out cardsEarned)) {
|
||||
if (!ushort.TryParse(cardsEarnedMatch.Value, out ushort cardsEarned)) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(cardsEarned));
|
||||
continue;
|
||||
}
|
||||
@@ -681,8 +674,7 @@ namespace ArchiSteamFarm {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ushort cardsRemaining;
|
||||
if (ushort.TryParse(match.Value, out cardsRemaining) && (cardsRemaining != 0)) {
|
||||
if (ushort.TryParse(match.Value, out ushort cardsRemaining) && (cardsRemaining != 0)) {
|
||||
return cardsRemaining;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace ArchiSteamFarm {
|
||||
private readonly object FileLock = new object();
|
||||
|
||||
internal uint CellID {
|
||||
get { return _CellID; }
|
||||
get => _CellID;
|
||||
set {
|
||||
if ((value == 0) || (_CellID == value)) {
|
||||
return;
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace ArchiSteamFarm.JSON {
|
||||
}
|
||||
|
||||
internal MobileAuthenticator.Confirmation Confirmation {
|
||||
get { return _Confirmation; }
|
||||
get => _Confirmation;
|
||||
|
||||
set {
|
||||
if (value == null) {
|
||||
@@ -237,7 +237,7 @@ namespace ArchiSteamFarm.JSON {
|
||||
[JsonProperty(PropertyName = "amount", Required = Required.Always)]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
private string AmountString {
|
||||
get { return Amount.ToString(); }
|
||||
get => Amount.ToString();
|
||||
|
||||
set {
|
||||
if (string.IsNullOrEmpty(value)) {
|
||||
@@ -245,8 +245,7 @@ namespace ArchiSteamFarm.JSON {
|
||||
return;
|
||||
}
|
||||
|
||||
uint amount;
|
||||
if (!uint.TryParse(value, out amount) || (amount == 0)) {
|
||||
if (!uint.TryParse(value, out uint amount) || (amount == 0)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(amount));
|
||||
return;
|
||||
}
|
||||
@@ -258,7 +257,7 @@ namespace ArchiSteamFarm.JSON {
|
||||
[JsonProperty(PropertyName = "appid", Required = Required.DisallowNull)]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
private string AppIDString {
|
||||
get { return AppID.ToString(); }
|
||||
get => AppID.ToString();
|
||||
|
||||
set {
|
||||
if (string.IsNullOrEmpty(value)) {
|
||||
@@ -266,8 +265,7 @@ namespace ArchiSteamFarm.JSON {
|
||||
return;
|
||||
}
|
||||
|
||||
uint appID;
|
||||
if (!uint.TryParse(value, out appID) || (appID == 0)) {
|
||||
if (!uint.TryParse(value, out uint appID) || (appID == 0)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(appID));
|
||||
return;
|
||||
}
|
||||
@@ -278,7 +276,7 @@ namespace ArchiSteamFarm.JSON {
|
||||
|
||||
[JsonProperty(PropertyName = "assetid", Required = Required.DisallowNull)]
|
||||
private string AssetIDString {
|
||||
get { return AssetID.ToString(); }
|
||||
get => AssetID.ToString();
|
||||
|
||||
set {
|
||||
if (string.IsNullOrEmpty(value)) {
|
||||
@@ -286,8 +284,7 @@ namespace ArchiSteamFarm.JSON {
|
||||
return;
|
||||
}
|
||||
|
||||
ulong assetID;
|
||||
if (!ulong.TryParse(value, out assetID) || (assetID == 0)) {
|
||||
if (!ulong.TryParse(value, out ulong assetID) || (assetID == 0)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(assetID));
|
||||
return;
|
||||
}
|
||||
@@ -299,7 +296,7 @@ namespace ArchiSteamFarm.JSON {
|
||||
[JsonProperty(PropertyName = "classid", Required = Required.DisallowNull)]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
private string ClassIDString {
|
||||
get { return ClassID.ToString(); }
|
||||
get => ClassID.ToString();
|
||||
|
||||
set {
|
||||
if (string.IsNullOrEmpty(value)) {
|
||||
@@ -307,8 +304,7 @@ namespace ArchiSteamFarm.JSON {
|
||||
return;
|
||||
}
|
||||
|
||||
ulong classID;
|
||||
if (!ulong.TryParse(value, out classID) || (classID == 0)) {
|
||||
if (!ulong.TryParse(value, out ulong classID) || (classID == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -319,7 +315,7 @@ namespace ArchiSteamFarm.JSON {
|
||||
[JsonProperty(PropertyName = "contextid", Required = Required.DisallowNull)]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
private string ContextIDString {
|
||||
get { return ContextID.ToString(); }
|
||||
get => ContextID.ToString();
|
||||
|
||||
set {
|
||||
if (string.IsNullOrEmpty(value)) {
|
||||
@@ -327,8 +323,7 @@ namespace ArchiSteamFarm.JSON {
|
||||
return;
|
||||
}
|
||||
|
||||
ulong contextID;
|
||||
if (!ulong.TryParse(value, out contextID) || (contextID == 0)) {
|
||||
if (!ulong.TryParse(value, out ulong contextID) || (contextID == 0)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(contextID));
|
||||
return;
|
||||
}
|
||||
@@ -340,8 +335,8 @@ namespace ArchiSteamFarm.JSON {
|
||||
[JsonProperty(PropertyName = "id", Required = Required.DisallowNull)]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
private string ID {
|
||||
get { return AssetIDString; }
|
||||
set { AssetIDString = value; }
|
||||
get => AssetIDString;
|
||||
set => AssetIDString = value;
|
||||
}
|
||||
|
||||
// Constructed from trades being received
|
||||
@@ -440,13 +435,11 @@ namespace ArchiSteamFarm.JSON {
|
||||
internal bool IsFairTypesExchange() {
|
||||
Dictionary<uint, Dictionary<Item.EType, uint>> itemsToGivePerGame = new Dictionary<uint, Dictionary<Item.EType, uint>>();
|
||||
foreach (Item item in ItemsToGive) {
|
||||
Dictionary<Item.EType, uint> itemsPerType;
|
||||
if (!itemsToGivePerGame.TryGetValue(item.RealAppID, out itemsPerType)) {
|
||||
if (!itemsToGivePerGame.TryGetValue(item.RealAppID, out Dictionary<Item.EType, uint> itemsPerType)) {
|
||||
itemsPerType = new Dictionary<Item.EType, uint> { [item.Type] = item.Amount };
|
||||
itemsToGivePerGame[item.RealAppID] = itemsPerType;
|
||||
} else {
|
||||
uint amount;
|
||||
if (itemsPerType.TryGetValue(item.Type, out amount)) {
|
||||
if (itemsPerType.TryGetValue(item.Type, out uint amount)) {
|
||||
itemsPerType[item.Type] = amount + item.Amount;
|
||||
} else {
|
||||
itemsPerType[item.Type] = item.Amount;
|
||||
@@ -456,16 +449,14 @@ namespace ArchiSteamFarm.JSON {
|
||||
|
||||
Dictionary<uint, Dictionary<Item.EType, uint>> itemsToReceivePerGame = new Dictionary<uint, Dictionary<Item.EType, uint>>();
|
||||
foreach (Item item in ItemsToReceive) {
|
||||
Dictionary<Item.EType, uint> itemsPerType;
|
||||
if (!itemsToReceivePerGame.TryGetValue(item.RealAppID, out itemsPerType)) {
|
||||
if (!itemsToReceivePerGame.TryGetValue(item.RealAppID, out Dictionary<Item.EType, uint> itemsPerType)) {
|
||||
itemsPerType = new Dictionary<Item.EType, uint> {
|
||||
{ item.Type, item.Amount }
|
||||
};
|
||||
|
||||
itemsToReceivePerGame[item.RealAppID] = itemsPerType;
|
||||
} else {
|
||||
uint amount;
|
||||
if (itemsPerType.TryGetValue(item.Type, out amount)) {
|
||||
if (itemsPerType.TryGetValue(item.Type, out uint amount)) {
|
||||
itemsPerType[item.Type] = amount + item.Amount;
|
||||
} else {
|
||||
itemsPerType[item.Type] = item.Amount;
|
||||
@@ -475,14 +466,12 @@ namespace ArchiSteamFarm.JSON {
|
||||
|
||||
// Ensure that amount of items to give is at least amount of items to receive (per game and per type)
|
||||
foreach (KeyValuePair<uint, Dictionary<Item.EType, uint>> itemsPerGame in itemsToGivePerGame) {
|
||||
Dictionary<Item.EType, uint> otherItemsPerType;
|
||||
if (!itemsToReceivePerGame.TryGetValue(itemsPerGame.Key, out otherItemsPerType)) {
|
||||
if (!itemsToReceivePerGame.TryGetValue(itemsPerGame.Key, out Dictionary<Item.EType, uint> otherItemsPerType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<Item.EType, uint> itemsPerType in itemsPerGame.Value) {
|
||||
uint otherAmount;
|
||||
if (!otherItemsPerType.TryGetValue(itemsPerType.Key, out otherAmount)) {
|
||||
if (!otherItemsPerType.TryGetValue(itemsPerType.Key, out uint otherAmount)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,8 +154,7 @@ namespace ArchiSteamFarm {
|
||||
return null;
|
||||
}
|
||||
|
||||
uint id;
|
||||
if (!uint.TryParse(idString, out id) || (id == 0)) {
|
||||
if (!uint.TryParse(idString, out uint id) || (id == 0)) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(id));
|
||||
return null;
|
||||
}
|
||||
@@ -166,8 +165,7 @@ namespace ArchiSteamFarm {
|
||||
return null;
|
||||
}
|
||||
|
||||
ulong key;
|
||||
if (!ulong.TryParse(keyString, out key) || (key == 0)) {
|
||||
if (!ulong.TryParse(keyString, out ulong key) || (key == 0)) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(key));
|
||||
return null;
|
||||
}
|
||||
@@ -248,13 +246,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
internal void Init(Bot bot) {
|
||||
if (bot == null) {
|
||||
throw new ArgumentNullException(nameof(bot));
|
||||
}
|
||||
|
||||
Bot = bot;
|
||||
}
|
||||
internal void Init(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
||||
|
||||
internal static async Task OnTimeChanged() {
|
||||
await TimeSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
|
||||
@@ -48,13 +48,7 @@ namespace ArchiSteamFarm {
|
||||
private string LastNickname;
|
||||
private bool ShouldSendHeartBeats;
|
||||
|
||||
internal Statistics(Bot bot) {
|
||||
if (bot == null) {
|
||||
throw new ArgumentNullException(nameof(bot));
|
||||
}
|
||||
|
||||
Bot = bot;
|
||||
}
|
||||
internal Statistics(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
||||
|
||||
public void Dispose() => Semaphore.Dispose();
|
||||
|
||||
|
||||
@@ -43,13 +43,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
private bool ParsingScheduled;
|
||||
|
||||
internal Trading(Bot bot) {
|
||||
if (bot == null) {
|
||||
throw new ArgumentNullException(nameof(bot));
|
||||
}
|
||||
|
||||
Bot = bot;
|
||||
}
|
||||
internal Trading(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
||||
|
||||
public void Dispose() => TradesSemaphore.Dispose();
|
||||
|
||||
@@ -269,8 +263,7 @@ namespace ArchiSteamFarm {
|
||||
// Now let's create a map which maps items to their amount in our EQ
|
||||
Dictionary<ulong, uint> amountMap = new Dictionary<ulong, uint>();
|
||||
foreach (Steam.Item item in inventory) {
|
||||
uint amount;
|
||||
if (amountMap.TryGetValue(item.ClassID, out amount)) {
|
||||
if (amountMap.TryGetValue(item.ClassID, out uint amount)) {
|
||||
amountMap[item.ClassID] = amount + item.Amount;
|
||||
} else {
|
||||
amountMap[item.ClassID] = item.Amount;
|
||||
@@ -281,8 +274,7 @@ namespace ArchiSteamFarm {
|
||||
List<uint> amountsToGive = new List<uint>(tradeOffer.ItemsToGive.Count);
|
||||
Dictionary<ulong, uint> amountMapToGive = new Dictionary<ulong, uint>(amountMap);
|
||||
foreach (ulong key in tradeOffer.ItemsToGive.Select(item => item.ClassID)) {
|
||||
uint amount;
|
||||
if (!amountMapToGive.TryGetValue(key, out amount)) {
|
||||
if (!amountMapToGive.TryGetValue(key, out uint amount)) {
|
||||
amountsToGive.Add(0);
|
||||
continue;
|
||||
}
|
||||
@@ -298,8 +290,7 @@ namespace ArchiSteamFarm {
|
||||
List<uint> amountsToReceive = new List<uint>(tradeOffer.ItemsToReceive.Count);
|
||||
Dictionary<ulong, uint> amountMapToReceive = new Dictionary<ulong, uint>(amountMap);
|
||||
foreach (ulong key in tradeOffer.ItemsToReceive.Select(item => item.ClassID)) {
|
||||
uint amount;
|
||||
if (!amountMapToReceive.TryGetValue(key, out amount)) {
|
||||
if (!amountMapToReceive.TryGetValue(key, out uint amount)) {
|
||||
amountsToReceive.Add(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -46,11 +46,7 @@ namespace ArchiSteamFarm {
|
||||
private readonly HttpClient HttpClient;
|
||||
|
||||
internal WebBrowser(ArchiLogger archiLogger) {
|
||||
if (archiLogger == null) {
|
||||
throw new ArgumentNullException(nameof(archiLogger));
|
||||
}
|
||||
|
||||
ArchiLogger = archiLogger;
|
||||
ArchiLogger = archiLogger ?? throw new ArgumentNullException(nameof(archiLogger));
|
||||
|
||||
HttpClientHandler httpClientHandler = new HttpClientHandler {
|
||||
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
|
||||
|
||||
@@ -31,11 +31,7 @@ namespace ConfigGenerator {
|
||||
internal readonly ASFConfig ASFConfig;
|
||||
|
||||
internal ConfigPage(ASFConfig config) {
|
||||
if (config == null) {
|
||||
throw new ArgumentNullException(nameof(config));
|
||||
}
|
||||
|
||||
ASFConfig = config;
|
||||
ASFConfig = config ?? throw new ArgumentNullException(nameof(config));
|
||||
|
||||
RefreshText();
|
||||
|
||||
|
||||
@@ -30,11 +30,7 @@ namespace ConfigGenerator {
|
||||
private readonly ASFConfig ASFConfig;
|
||||
|
||||
internal EnhancedPropertyGrid(ASFConfig config) {
|
||||
if (config == null) {
|
||||
throw new ArgumentNullException(nameof(config));
|
||||
}
|
||||
|
||||
ASFConfig = config;
|
||||
ASFConfig = config ?? throw new ArgumentNullException(nameof(config));
|
||||
|
||||
SelectedObject = config;
|
||||
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
|
||||
@@ -11,11 +11,7 @@ namespace ArchiSteamFarm {
|
||||
private readonly Bot Bot;
|
||||
|
||||
internal BotStatusForm(Bot bot) {
|
||||
if (bot == null) {
|
||||
throw new ArgumentNullException(nameof(bot));
|
||||
}
|
||||
|
||||
Bot = bot;
|
||||
Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
||||
|
||||
BotForms[bot.BotName] = this;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user