From c60b14fe599e71dd701b5b83dc8554607ade062a Mon Sep 17 00:00:00 2001 From: Golovin Gleb Date: Thu, 30 Apr 2015 20:17:55 +0600 Subject: [PATCH] Add status command implementation --- .../CommandExecutors/StatusExecutor.cs | 24 +++++++++ .../CommandHelpers/BuildInfo.cs | 32 +++++++++++ .../CommandHelpers/OSInfo.cs | 53 +++++++++++++++++++ .../Winium.Desktop.Driver.csproj | 3 ++ 4 files changed, 112 insertions(+) create mode 100644 src/Winium.Desktop.Driver/CommandExecutors/StatusExecutor.cs create mode 100644 src/Winium.Desktop.Driver/CommandHelpers/BuildInfo.cs create mode 100644 src/Winium.Desktop.Driver/CommandHelpers/OSInfo.cs diff --git a/src/Winium.Desktop.Driver/CommandExecutors/StatusExecutor.cs b/src/Winium.Desktop.Driver/CommandExecutors/StatusExecutor.cs new file mode 100644 index 0000000..f1a4fb6 --- /dev/null +++ b/src/Winium.Desktop.Driver/CommandExecutors/StatusExecutor.cs @@ -0,0 +1,24 @@ +namespace Winium.Desktop.Driver.CommandExecutors +{ + #region using + + using System.Collections.Generic; + + using Winium.Desktop.Driver.CommandHelpers; + using Winium.StoreApps.Common; + + #endregion + + internal class StatusExecutor : CommandExecutorBase + { + #region Methods + + protected override string DoImpl() + { + var response = new Dictionary { { "build", new BuildInfo() }, { "os", new OSInfo() } }; + return this.JsonResponse(ResponseStatus.Success, response); + } + + #endregion + } +} diff --git a/src/Winium.Desktop.Driver/CommandHelpers/BuildInfo.cs b/src/Winium.Desktop.Driver/CommandHelpers/BuildInfo.cs new file mode 100644 index 0000000..607a48c --- /dev/null +++ b/src/Winium.Desktop.Driver/CommandHelpers/BuildInfo.cs @@ -0,0 +1,32 @@ +namespace Winium.Desktop.Driver.CommandHelpers +{ + #region using + + using System.Reflection; + + using Newtonsoft.Json; + + #endregion + + public class BuildInfo + { + #region Static Fields + + private static string version; + + #endregion + + #region Public Properties + + [JsonProperty("version")] + public string Version + { + get + { + return version ?? (version = Assembly.GetExecutingAssembly().GetName().Version.ToString()); + } + } + + #endregion + } +} diff --git a/src/Winium.Desktop.Driver/CommandHelpers/OSInfo.cs b/src/Winium.Desktop.Driver/CommandHelpers/OSInfo.cs new file mode 100644 index 0000000..ecb2435 --- /dev/null +++ b/src/Winium.Desktop.Driver/CommandHelpers/OSInfo.cs @@ -0,0 +1,53 @@ +namespace Winium.Desktop.Driver.CommandHelpers +{ + #region using + + using System; + + using Newtonsoft.Json; + + #endregion + + // ReSharper disable once InconsistentNaming + public class OSInfo + { + #region Static Fields + + private static string architecture; + + private static string version; + + #endregion + + #region Public Properties + + [JsonProperty("arch")] + public string Architecture + { + get + { + return architecture ?? (architecture = Environment.Is64BitOperatingSystem ? "x64" : "x86"); + } + } + + [JsonProperty("name")] + public string Name + { + get + { + return "windows"; + } + } + + [JsonProperty("version")] + public string Version + { + get + { + return version ?? (version = Environment.OSVersion.VersionString); + } + } + + #endregion + } +} diff --git a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj index 578da44..7888a6c 100644 --- a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj +++ b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj @@ -64,6 +64,7 @@ + @@ -103,6 +104,8 @@ + +