Avoid serializing default properties in databases

Less data to read/write is always better.
This commit is contained in:
JustArchi
2019-01-02 18:24:25 +01:00
parent 5f33512658
commit 7a3f6ddef9
3 changed files with 19 additions and 0 deletions

View File

@@ -340,5 +340,15 @@ namespace ArchiSteamFarm {
FileSemaphore.Release();
}
}
// ReSharper disable UnusedMember.Global
public bool ShouldSerializeBlacklistedFromTradesSteamIDs() => BlacklistedFromTradesSteamIDs.Count > 0;
public bool ShouldSerializeGamesToRedeemInBackground() => HasGamesToRedeemInBackground;
public bool ShouldSerializeIdlingBlacklistedAppIDs() => IdlingBlacklistedAppIDs.Count > 0;
public bool ShouldSerializeIdlingPriorityAppIDs() => IdlingPriorityAppIDs.Count > 0;
public bool ShouldSerializeLoginKey() => !string.IsNullOrEmpty(LoginKey);
public bool ShouldSerializeMobileAuthenticator() => MobileAuthenticator != null;
// ReSharper restore UnusedMember.Global
}
}

View File

@@ -182,5 +182,12 @@ namespace ArchiSteamFarm {
FileSemaphore.Release();
}
}
// ReSharper disable UnusedMember.Global
public bool ShouldSerializeCellID() => CellID != 0;
public bool ShouldSerializePackagesData() => PackagesData.Count > 0;
public bool ShouldSerializeServerListProvider() => ServerListProvider.ShouldSerializeServerRecords();
// ReSharper restore UnusedMember.Global
}
}

View File

@@ -52,6 +52,8 @@ namespace ArchiSteamFarm.SteamKit2 {
return Task.CompletedTask;
}
public bool ShouldSerializeServerRecords() => ServerRecords.Count > 0;
internal event EventHandler ServerListUpdated;
}
}