C# 7.0 syntax sugars

This commit is contained in:
Bruno Logerfo
2017-03-14 08:20:29 -03:00
parent 6c8a123b68
commit f8b2fcda7a
14 changed files with 62 additions and 150 deletions

View File

@@ -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;
}