From 0c1859f848128e85aa46746a5c593d78832e7c66 Mon Sep 17 00:00:00 2001 From: Vincent Maas Date: Sun, 27 Feb 2022 15:23:46 +0100 Subject: [PATCH] add spanish translations to restart detector --- ColorControl/ColorControl.csproj | 4 ++-- ColorControl/RestartDetector.cs | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ColorControl/ColorControl.csproj b/ColorControl/ColorControl.csproj index bcca5c8..0acde43 100644 --- a/ColorControl/ColorControl.csproj +++ b/ColorControl/ColorControl.csproj @@ -18,8 +18,8 @@ Maassoft Maassoft 0 - 5.5.0.0 - 5.5.0.0 + 5.5.1.0 + 5.5.1.0 false true false diff --git a/ColorControl/RestartDetector.cs b/ColorControl/RestartDetector.cs index e1811a4..1360328 100644 --- a/ColorControl/RestartDetector.cs +++ b/ColorControl/RestartDetector.cs @@ -1,6 +1,7 @@ using Microsoft.Win32; using NLog; using System; +using System.Collections.Generic; using System.Diagnostics.Eventing.Reader; using System.Linq; @@ -14,6 +15,9 @@ namespace ColorControl private EventLogWatcher watcher = null; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + private static readonly IEnumerable RestartNames = new[] { "restart", "herstart", "reinicio" }; + private static readonly IEnumerable PowerOffNames = new[] { "power off", "uitschakelen", "apagar" }; + public RestartDetector() { try @@ -56,13 +60,14 @@ namespace ColorControl { foreach (EventProperty x in ((EventLogRecord)arg.EventRecord).Properties) { - Logger.Debug("Event value: " + x.Value); - if (x.Value.Equals("restart")) + var strValue = x.Value.ToString(); + Logger.Debug("Event value: " + strValue); + if (RestartNames.Any(n => n.Equals(strValue, StringComparison.OrdinalIgnoreCase))) { RestartDetected = true; break; } - if (x.Value.Equals("power off")) + if (PowerOffNames.Any(n => n.Equals(strValue, StringComparison.OrdinalIgnoreCase))) { PowerOffDetected = true; break;