Add BuildVariant to GET /Api/ASF - Implement feature-request #859 (#860)

* Add OSVariant to GET /Api/ASF

* Change order of checks and strings in exception to match constructor

* Rename OSVariant to BuildVariant and keep alphabetic order

* Change call of constructor to match actual constructor

* Add missing parenthesis and nameof(globalConfig)
This commit is contained in:
Abrynos
2018-07-19 17:27:25 +02:00
committed by Łukasz Domeradzki
parent befba3280f
commit 7567aefdc6

View File

@@ -230,7 +230,7 @@ namespace ArchiSteamFarm {
processStartTime = process.StartTime;
}
ASFResponse asfResponse = new ASFResponse(Program.GlobalConfig, memoryUsage, processStartTime, SharedInfo.Version);
ASFResponse asfResponse = new ASFResponse(SharedInfo.BuildInfo.Variant, Program.GlobalConfig, memoryUsage, processStartTime, SharedInfo.Version);
await ResponseJsonObject(request, response, new GenericResponse<ASFResponse>(true, "OK", asfResponse)).ConfigureAwait(false);
return true;
@@ -1301,6 +1301,9 @@ namespace ArchiSteamFarm {
}
private sealed class ASFResponse {
[JsonProperty]
private readonly string BuildVariant;
[JsonProperty]
private readonly GlobalConfig GlobalConfig;
@@ -1313,11 +1316,12 @@ namespace ArchiSteamFarm {
[JsonProperty]
private readonly Version Version;
internal ASFResponse(GlobalConfig globalConfig, uint memoryUsage, DateTime processStartTime, Version version) {
if ((globalConfig == null) || (memoryUsage == 0) || (processStartTime == DateTime.MinValue) || (version == null)) {
throw new ArgumentNullException(nameof(memoryUsage) + " || " + nameof(processStartTime) + " || " + nameof(version));
internal ASFResponse(string buildVariant, GlobalConfig globalConfig, uint memoryUsage, DateTime processStartTime, Version version) {
if ((string.IsNullOrEmpty(buildVariant)) || (globalConfig == null) || (memoryUsage == 0) || (processStartTime == DateTime.MinValue) || (version == null)) {
throw new ArgumentNullException(nameof(buildVariant) + " || " + nameof(globalConfig) + " || " + nameof(memoryUsage) + " || " + nameof(processStartTime) + " || " + nameof(version));
}
BuildVariant = buildVariant;
GlobalConfig = globalConfig;
MemoryUsage = memoryUsage;
ProcessStartTime = processStartTime;