fix: Ignoring Crestron ethernet parameters that say "Invalid Value"

This commit is contained in:
Chris Cameron
2020-01-16 15:51:05 -05:00
parent 49f8f116fd
commit 89f0214cce
2 changed files with 17 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed ### Changed
- Network/MAC/DNS address utils are now enumerating all adapter types - Network/MAC/DNS address utils are now enumerating all adapter types
- Ignoring Crestron ethernet parameters that say "Invalid Value"
## [10.2.0] - 2019-12-04 ## [10.2.0] - 2019-12-04
### Added ### Added

View File

@@ -1,14 +1,19 @@
using ICD.Common.Utils.Extensions; #if SIMPLSHARP
#if SIMPLSHARP
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using ICD.Common.Properties; using ICD.Common.Properties;
using ICD.Common.Utils.Extensions;
namespace ICD.Common.Utils namespace ICD.Common.Utils
{ {
public static partial class IcdEnvironment public static partial class IcdEnvironment
{ {
/// <summary>
/// For some reason crestron returns "Invalid Value" for ethernet parameters sometimes :/
/// </summary>
private const string INVALID_VALUE = "Invalid Value";
#region Properties #region Properties
public static string NewLine { get { return CrestronEnvironment.NewLine; } } public static string NewLine { get { return CrestronEnvironment.NewLine; } }
@@ -48,7 +53,7 @@ namespace ICD.Common.Utils
continue; continue;
} }
if (!string.IsNullOrEmpty(address)) if (!string.IsNullOrEmpty(address) && !address.Equals(INVALID_VALUE))
yield return address; yield return address;
} }
} }
@@ -79,7 +84,7 @@ namespace ICD.Common.Utils
continue; continue;
} }
if (!string.IsNullOrEmpty(macAddress)) if (!string.IsNullOrEmpty(macAddress) && !macAddress.Equals(INVALID_VALUE))
yield return macAddress; yield return macAddress;
} }
} }
@@ -100,7 +105,12 @@ namespace ICD.Common.Utils
try try
{ {
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type); short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type);
return CrestronEthernetHelper.GetEthernetParameter(param, id); string status = CrestronEthernetHelper.GetEthernetParameter(param, id);
if (!string.IsNullOrEmpty(status) && !status.Equals(INVALID_VALUE))
return status;
return null;
} }
catch (ArgumentException) catch (ArgumentException)
{ {
@@ -134,7 +144,7 @@ namespace ICD.Common.Utils
continue; continue;
} }
if (!string.IsNullOrEmpty(hostname)) if (!string.IsNullOrEmpty(hostname) && !hostname.Equals(INVALID_VALUE))
yield return hostname; yield return hostname;
} }
} }