mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
feat: Simplifying network interfaces, enumerating all adapter types
# Conflicts: # CHANGELOG.md
This commit is contained in:
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Network/MAC/DNS address utils are now enumerating all adapter types
|
||||||
|
|
||||||
## [10.2.0] - 2019-12-04
|
## [10.2.0] - 2019-12-04
|
||||||
### Added
|
### Added
|
||||||
- Added shim methods for finding closest DateTimes from a sequence
|
- Added shim methods for finding closest DateTimes from a sequence
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ namespace ICD.Common.Utils
|
|||||||
{
|
{
|
||||||
public static partial class IcdEnvironment
|
public static partial class IcdEnvironment
|
||||||
{
|
{
|
||||||
|
#region Properties
|
||||||
|
|
||||||
public static string NewLine { get { return CrestronEnvironment.NewLine; } }
|
public static string NewLine { get { return CrestronEnvironment.NewLine; } }
|
||||||
|
|
||||||
public static eRuntimeEnvironment RuntimeEnvironment
|
public static eRuntimeEnvironment RuntimeEnvironment
|
||||||
@@ -31,36 +33,24 @@ namespace ICD.Common.Utils
|
|||||||
{
|
{
|
||||||
const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param =
|
const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param =
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS;
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS;
|
||||||
const EthernetAdapterType primaryType = EthernetAdapterType.EthernetLANAdapter;
|
|
||||||
const EthernetAdapterType secondaryType = EthernetAdapterType.EthernetLAN2Adapter;
|
|
||||||
|
|
||||||
string address1 = null;
|
foreach (EthernetAdapterType type in EnumUtils.GetValuesExceptNone<EthernetAdapterType>())
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(primaryType);
|
string address;
|
||||||
address1 = CrestronEthernetHelper.GetEthernetParameter(param, id);
|
|
||||||
}
|
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(address1))
|
|
||||||
yield return address1;
|
|
||||||
|
|
||||||
string address2 = null;
|
try
|
||||||
|
{
|
||||||
|
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type);
|
||||||
|
address = CrestronEthernetHelper.GetEthernetParameter(param, id);
|
||||||
|
}
|
||||||
|
catch (ArgumentException)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
if (!string.IsNullOrEmpty(address))
|
||||||
{
|
yield return address;
|
||||||
short adapter2Type = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(secondaryType);
|
|
||||||
address2 = CrestronEthernetHelper.GetEthernetParameter(param, adapter2Type);
|
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(address2))
|
|
||||||
yield return address2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,36 +64,24 @@ namespace ICD.Common.Utils
|
|||||||
{
|
{
|
||||||
const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param =
|
const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param =
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS;
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS;
|
||||||
const EthernetAdapterType primaryType = EthernetAdapterType.EthernetLANAdapter;
|
|
||||||
const EthernetAdapterType secondaryType = EthernetAdapterType.EthernetLAN2Adapter;
|
|
||||||
|
|
||||||
string macAddress1 = null;
|
foreach (EthernetAdapterType type in EnumUtils.GetValuesExceptNone<EthernetAdapterType>())
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(primaryType);
|
string macAddress;
|
||||||
macAddress1 = CrestronEthernetHelper.GetEthernetParameter(param, id);
|
|
||||||
}
|
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(macAddress1))
|
try
|
||||||
yield return macAddress1;
|
{
|
||||||
|
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type);
|
||||||
|
macAddress = CrestronEthernetHelper.GetEthernetParameter(param, id);
|
||||||
|
}
|
||||||
|
catch (ArgumentException)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
string macAddress2 = null;
|
if (!string.IsNullOrEmpty(macAddress))
|
||||||
|
yield return macAddress;
|
||||||
try
|
|
||||||
{
|
|
||||||
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(secondaryType);
|
|
||||||
macAddress2 = CrestronEthernetHelper.GetEthernetParameter(param, id);
|
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(macAddress2))
|
|
||||||
yield return macAddress2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,40 +119,29 @@ namespace ICD.Common.Utils
|
|||||||
{
|
{
|
||||||
const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param =
|
const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param =
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME;
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME;
|
||||||
const EthernetAdapterType primaryType = EthernetAdapterType.EthernetLANAdapter;
|
|
||||||
const EthernetAdapterType secondaryType = EthernetAdapterType.EthernetLAN2Adapter;
|
|
||||||
|
|
||||||
string address1 = null;
|
foreach (EthernetAdapterType type in EnumUtils.GetValuesExceptNone<EthernetAdapterType>())
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(primaryType);
|
string hostname;
|
||||||
address1 = CrestronEthernetHelper.GetEthernetParameter(param, id);
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type);
|
||||||
|
hostname = CrestronEthernetHelper.GetEthernetParameter(param, id);
|
||||||
|
}
|
||||||
|
catch (ArgumentException)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(hostname))
|
||||||
|
yield return hostname;
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(address1))
|
|
||||||
yield return address1;
|
|
||||||
|
|
||||||
string address2 = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
short adapter2Type = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(secondaryType);
|
|
||||||
address2 = CrestronEthernetHelper.GetEthernetParameter(param, adapter2Type);
|
|
||||||
}
|
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(address2))
|
|
||||||
yield return address2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Static constructor.
|
/// Static constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user