mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-06 17:10:13 +00:00
Syntax improvements
This commit is contained in:
@@ -102,7 +102,7 @@ public static class ASF {
|
||||
return fileType switch {
|
||||
EFileType.Config => Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalConfigFileName),
|
||||
EFileType.Database => Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalDatabaseFileName),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(fileType))
|
||||
_ => throw new InvalidOperationException(nameof(fileType))
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -129,13 +129,8 @@ public abstract class SerializableFile : IDisposable {
|
||||
}
|
||||
|
||||
internal static async Task<bool> Write(string filePath, string json) {
|
||||
if (string.IsNullOrEmpty(filePath)) {
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(json)) {
|
||||
throw new ArgumentNullException(nameof(json));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(filePath);
|
||||
ArgumentException.ThrowIfNullOrEmpty(json);
|
||||
|
||||
string newFilePath = $"{filePath}.new";
|
||||
|
||||
|
||||
@@ -80,11 +80,7 @@ public sealed class ASFResponse {
|
||||
ArgumentException.ThrowIfNullOrEmpty(buildVariant);
|
||||
ArgumentNullException.ThrowIfNull(globalConfig);
|
||||
ArgumentOutOfRangeException.ThrowIfZero(memoryUsage);
|
||||
|
||||
// TODO: Use this instead once we get rid of generic-netf
|
||||
//ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(processStartTime, DateTime.UnixEpoch);
|
||||
ArgumentOutOfRangeException.ThrowIfEqual(processStartTime, DateTime.MinValue);
|
||||
|
||||
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(processStartTime, DateTime.UnixEpoch);
|
||||
ArgumentNullException.ThrowIfNull(version);
|
||||
|
||||
BuildVariant = buildVariant;
|
||||
|
||||
@@ -42,9 +42,13 @@ public sealed class Game : IEquatable<Game> {
|
||||
internal uint PlayableAppID { get; set; }
|
||||
|
||||
internal Game(uint appID, string gameName, float hoursPlayed, ushort cardsRemaining, byte badgeLevel) {
|
||||
AppID = appID > 0 ? appID : throw new ArgumentOutOfRangeException(nameof(appID));
|
||||
GameName = !string.IsNullOrEmpty(gameName) ? gameName : throw new ArgumentNullException(nameof(gameName));
|
||||
HoursPlayed = hoursPlayed >= 0 ? hoursPlayed : throw new ArgumentOutOfRangeException(nameof(hoursPlayed));
|
||||
ArgumentOutOfRangeException.ThrowIfZero(appID);
|
||||
ArgumentException.ThrowIfNullOrEmpty(gameName);
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(hoursPlayed);
|
||||
|
||||
AppID = appID;
|
||||
GameName = gameName;
|
||||
HoursPlayed = hoursPlayed;
|
||||
CardsRemaining = cardsRemaining;
|
||||
BadgeLevel = badgeLevel;
|
||||
|
||||
|
||||
@@ -132,7 +132,11 @@ public sealed class BotDatabase : GenericDatabase {
|
||||
[JsonProperty]
|
||||
private string? BackingSteamGuardData;
|
||||
|
||||
private BotDatabase(string filePath) : this() => FilePath = !string.IsNullOrEmpty(filePath) ? filePath : throw new ArgumentNullException(nameof(filePath));
|
||||
private BotDatabase(string filePath) : this() {
|
||||
ArgumentException.ThrowIfNullOrEmpty(filePath);
|
||||
|
||||
FilePath = filePath;
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
private BotDatabase() {
|
||||
|
||||
Reference in New Issue
Block a user