Code review

This commit is contained in:
JustArchi
2016-10-01 00:36:48 +02:00
parent 676409eb56
commit e3534f4440
2 changed files with 11 additions and 27 deletions

View File

@@ -138,7 +138,7 @@ namespace ArchiSteamFarm {
return false;
}
uint realAppID = 0;
uint realAppID = appID;
Steam.Item.EType type = Steam.Item.EType.Unknown;
Tuple<uint, Steam.Item.EType> description;
@@ -820,12 +820,12 @@ namespace ArchiSteamFarm {
}
bool more;
if (!bool.TryParse(jObject["more"].ToString(), out more) || !more) {
if (!bool.TryParse(jObject["more"]?.ToString(), out 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 nextPage) || (nextPage <= currentPage)) {
Logging.LogNullError(nameof(nextPage), Bot.BotName);
return null;
}
@@ -867,7 +867,7 @@ namespace ArchiSteamFarm {
itemID = 0;
}
singleTrade.ItemsToGive.Assets.Add(new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, item.AssetID, item.Amount));
singleTrade.ItemsToGive.Assets.Add(item);
itemID++;
}

View File

@@ -101,7 +101,7 @@ namespace ArchiSteamFarm.JSON {
}
}
internal ulong AssetID { get; private set; }
private ulong AssetID;
[JsonProperty(PropertyName = "assetid", Required = Required.DisallowNull)]
private string AssetIDString {
@@ -184,38 +184,22 @@ namespace ArchiSteamFarm.JSON {
internal uint RealAppID { get; set; }
internal EType Type { get; set; }
// This constructor is used for constructing items in trades being sent
internal Item(uint appID, ulong contextID, ulong assetID, uint amount) : this(appID, contextID, amount) {
if (assetID == 0) {
throw new ArgumentNullException(nameof(assetID));
}
AssetID = assetID;
}
// This constructor is used for constructing items in trades being received
internal Item(uint appID, ulong contextID, ulong classID, uint amount, uint realAppID, EType type) : this(appID, contextID, amount) {
if (classID == 0) {
throw new ArgumentNullException(nameof(classID));
internal Item(uint appID, ulong contextID, ulong classID, uint amount, uint realAppID, EType type) {
if ((appID == 0) || (contextID == 0) || (classID == 0) || (amount == 0) || (realAppID == 0)) {
throw new ArgumentNullException(nameof(classID) + " || " + nameof(contextID) + " || " + nameof(classID) + " || " + nameof(amount) + " || " + nameof(realAppID));
}
AppID = appID;
ContextID = contextID;
ClassID = classID;
Amount = amount;
RealAppID = realAppID;
Type = type;
}
[SuppressMessage("ReSharper", "UnusedMember.Local")]
private Item() { }
private Item(uint appID, ulong contextID, uint amount) {
if ((appID == 0) || (contextID == 0) || (amount == 0)) {
throw new ArgumentNullException(nameof(appID) + " || " + nameof(contextID) + " || " + nameof(amount));
}
AppID = appID;
ContextID = contextID;
Amount = amount;
}
}
internal sealed class TradeOffer { // REF: https://developer.valvesoftware.com/wiki/Steam_Web_API/IEconService#CEcon_TradeOffer | Constructed from code