mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-16 06:20:34 +00:00
Use new C# features for serializable files
This commit is contained in:
@@ -41,54 +41,51 @@ internal sealed class BotCache : SerializableFile {
|
||||
[JsonObjectCreationHandling(JsonObjectCreationHandling.Populate)]
|
||||
internal ConcurrentList<AssetForListing> LastAnnouncedAssetsForListing { get; private init; } = [];
|
||||
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("BackingLastAnnouncedTradeToken")]
|
||||
internal string? LastAnnouncedTradeToken {
|
||||
get => BackingLastAnnouncedTradeToken;
|
||||
get;
|
||||
|
||||
set {
|
||||
if (BackingLastAnnouncedTradeToken == value) {
|
||||
if (field == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
BackingLastAnnouncedTradeToken = value;
|
||||
field = value;
|
||||
Utilities.InBackground(Save);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("BackingLastInventoryChecksumBeforeDeduplication")]
|
||||
internal string? LastInventoryChecksumBeforeDeduplication {
|
||||
get => BackingLastInventoryChecksumBeforeDeduplication;
|
||||
get;
|
||||
|
||||
set {
|
||||
if (BackingLastInventoryChecksumBeforeDeduplication == value) {
|
||||
if (field == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
BackingLastInventoryChecksumBeforeDeduplication = value;
|
||||
field = value;
|
||||
Utilities.InBackground(Save);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("BackingLastRequestAt")]
|
||||
internal DateTime? LastRequestAt {
|
||||
get => BackingLastRequestAt;
|
||||
get;
|
||||
|
||||
set {
|
||||
if (BackingLastRequestAt == value) {
|
||||
if (field == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
BackingLastRequestAt = value;
|
||||
field = value;
|
||||
Utilities.InBackground(Save);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
private string? BackingLastAnnouncedTradeToken { get; set; }
|
||||
|
||||
[JsonInclude]
|
||||
private string? BackingLastInventoryChecksumBeforeDeduplication { get; set; }
|
||||
|
||||
[JsonInclude]
|
||||
private DateTime? BackingLastRequestAt { get; set; }
|
||||
|
||||
private BotCache(string filePath) : this() {
|
||||
ArgumentException.ThrowIfNullOrEmpty(filePath);
|
||||
|
||||
@@ -98,18 +95,18 @@ internal sealed class BotCache : SerializableFile {
|
||||
[JsonConstructor]
|
||||
private BotCache() => LastAnnouncedAssetsForListing.OnModified += OnObjectModified;
|
||||
|
||||
[UsedImplicitly]
|
||||
public bool ShouldSerializeBackingLastAnnouncedTradeToken() => !string.IsNullOrEmpty(BackingLastAnnouncedTradeToken);
|
||||
|
||||
[UsedImplicitly]
|
||||
public bool ShouldSerializeBackingLastInventoryChecksumBeforeDeduplication() => !string.IsNullOrEmpty(BackingLastInventoryChecksumBeforeDeduplication);
|
||||
|
||||
[UsedImplicitly]
|
||||
public bool ShouldSerializeBackingLastRequestAt() => BackingLastRequestAt.HasValue;
|
||||
|
||||
[UsedImplicitly]
|
||||
public bool ShouldSerializeLastAnnouncedAssetsForListing() => LastAnnouncedAssetsForListing.Count > 0;
|
||||
|
||||
[UsedImplicitly]
|
||||
public bool ShouldSerializeLastAnnouncedTradeToken() => !string.IsNullOrEmpty(LastAnnouncedTradeToken);
|
||||
|
||||
[UsedImplicitly]
|
||||
public bool ShouldSerializeLastInventoryChecksumBeforeDeduplication() => !string.IsNullOrEmpty(LastInventoryChecksumBeforeDeduplication);
|
||||
|
||||
[UsedImplicitly]
|
||||
public bool ShouldSerializeLastRequestAt() => LastRequestAt.HasValue;
|
||||
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
// Events we registered
|
||||
|
||||
Reference in New Issue
Block a user