fix: Fixing DHCP status return type and Hostnames property name

This commit is contained in:
Chris Cameron
2020-07-01 16:39:14 -04:00
parent d31b698cea
commit 99945b41a4
2 changed files with 11 additions and 13 deletions

View File

@@ -100,7 +100,7 @@ namespace ICD.Common.Utils
/// Gets the dhcp status of the processor. /// Gets the dhcp status of the processor.
/// </summary> /// </summary>
[PublicAPI] [PublicAPI]
public static string DhcpStatus public static bool DhcpStatus
{ {
get get
{ {
@@ -112,18 +112,18 @@ namespace ICD.Common.Utils
{ {
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type); short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type);
if (id >= InitialParametersClass.NumberOfEthernetInterfaces) if (id >= InitialParametersClass.NumberOfEthernetInterfaces)
return null; return false;
string status = CrestronEthernetHelper.GetEthernetParameter(param, id); string status = CrestronEthernetHelper.GetEthernetParameter(param, id);
if (!string.IsNullOrEmpty(status) && !status.Equals(INVALID_VALUE)) if (!string.IsNullOrEmpty(status) && !status.Equals(INVALID_VALUE))
return status; return status == "ON";
return null; return false;
} }
catch (ArgumentException) catch (ArgumentException)
{ {
return null; return false;
} }
} }
} }
@@ -132,7 +132,7 @@ namespace ICD.Common.Utils
/// Gets the hostname of the processor. /// Gets the hostname of the processor.
/// </summary> /// </summary>
[PublicAPI] [PublicAPI]
public static IEnumerable<string> Hostname public static IEnumerable<string> Hostnames
{ {
get get
{ {

View File

@@ -53,24 +53,22 @@ namespace ICD.Common.Utils
/// Gets the dhcp status of the processor. /// Gets the dhcp status of the processor.
/// </summary> /// </summary>
[PublicAPI] [PublicAPI]
public static string DhcpStatus public static bool DhcpStatus
{ {
get get
{ {
try try
{ {
bool enabled = return
NetworkInterface.GetAllNetworkInterfaces() NetworkInterface.GetAllNetworkInterfaces()
.Where(ni => ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || .Where(ni => ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 ||
ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet) ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
.Select(ni => ni.GetIPProperties().GetIPv4Properties().IsDhcpEnabled) .Select(ni => ni.GetIPProperties().GetIPv4Properties().IsDhcpEnabled)
.FirstOrDefault(); .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. /// Gets the hostname of the processor.
/// </summary> /// </summary>
[PublicAPI] [PublicAPI]
public static IEnumerable<string> Hostname { get { yield return Dns.GetHostName(); } } public static IEnumerable<string> Hostnames { get { yield return Dns.GetHostName(); } }
public static DateTime GetLocalTime() public static DateTime GetLocalTime()
{ {