From 99945b41a472ca285fe6b23569876e022a32b12c Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Wed, 1 Jul 2020 16:39:14 -0400 Subject: [PATCH] fix: Fixing DHCP status return type and Hostnames property name --- ICD.Common.Utils/IcdEnvironment.SimplSharp.cs | 12 ++++++------ ICD.Common.Utils/IcdEnvironment.Standard.cs | 12 +++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs index e43e2fa..df8795f 100644 --- a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs +++ b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs @@ -100,7 +100,7 @@ namespace ICD.Common.Utils /// Gets the dhcp status of the processor. /// [PublicAPI] - public static string DhcpStatus + public static bool DhcpStatus { get { @@ -112,18 +112,18 @@ namespace ICD.Common.Utils { short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type); if (id >= InitialParametersClass.NumberOfEthernetInterfaces) - return null; + return false; string status = CrestronEthernetHelper.GetEthernetParameter(param, id); if (!string.IsNullOrEmpty(status) && !status.Equals(INVALID_VALUE)) - return status; + return status == "ON"; - return null; + return false; } catch (ArgumentException) { - return null; + return false; } } } @@ -132,7 +132,7 @@ namespace ICD.Common.Utils /// Gets the hostname of the processor. /// [PublicAPI] - public static IEnumerable Hostname + public static IEnumerable Hostnames { get { diff --git a/ICD.Common.Utils/IcdEnvironment.Standard.cs b/ICD.Common.Utils/IcdEnvironment.Standard.cs index d734cc2..c735ca8 100644 --- a/ICD.Common.Utils/IcdEnvironment.Standard.cs +++ b/ICD.Common.Utils/IcdEnvironment.Standard.cs @@ -53,24 +53,22 @@ namespace ICD.Common.Utils /// Gets the dhcp status of the processor. /// [PublicAPI] - public static string DhcpStatus + public static bool DhcpStatus { get { try { - bool enabled = + return NetworkInterface.GetAllNetworkInterfaces() .Where(ni => ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet) .Select(ni => ni.GetIPProperties().GetIPv4Properties().IsDhcpEnabled) .FirstOrDefault(); - - return enabled.ToString(); } - catch(PlatformNotSupportedException) + catch (PlatformNotSupportedException) { - return false.ToString(); + return false; } } } @@ -79,7 +77,7 @@ namespace ICD.Common.Utils /// Gets the hostname of the processor. /// [PublicAPI] - public static IEnumerable Hostname { get { yield return Dns.GetHostName(); } } + public static IEnumerable Hostnames { get { yield return Dns.GetHostName(); } } public static DateTime GetLocalTime() {