From 7567aefdc6f6fd50f64edc199e144c7dd4ec2939 Mon Sep 17 00:00:00 2001 From: Abrynos <6608231+Abrynos@users.noreply.github.com> Date: Thu, 19 Jul 2018 17:27:25 +0200 Subject: [PATCH] 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) --- ArchiSteamFarm/IPC.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ArchiSteamFarm/IPC.cs b/ArchiSteamFarm/IPC.cs index 01b3364e1..2e9b6340f 100644 --- a/ArchiSteamFarm/IPC.cs +++ b/ArchiSteamFarm/IPC.cs @@ -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(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;