Files
tbf/TBF/Rig/Network/FtpAdapterInfo.cs
2024-03-10 22:24:03 +01:00

63 lines
2.0 KiB
C#

using System.Collections.Generic;
using System.Net.NetworkInformation;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Network
{
public class FtpAdapterInfo
{
public string Description;
/// Description of the network adapter.
public string Path;
/// common path to Ftp
public IValve TriggerValve;
/// valve to open reach trigger
public FtpAdapterInfo(string description)
{
Description = description;
}
///------------------------------------------------------
/// Static members and functions
///------------------------------------------------------
/// <summary>
/// Private list of the available network adapters.
/// </summary>
static List<FtpAdapterInfo> netAdapters;
/// <summary>
/// Retrieves the list of network adapters.
/// Never returns 'null', calls RefreshNetAdaptersInfo() the first time it is used.
/// If you want to refresh the list of the network adapters later, explicitly call
/// the RefreshNetAdaptersInfo() method.
/// </summary>
public static List<FtpAdapterInfo> NetAdapters
{
get
{
if (netAdapters == null) RefreshNetAdaptersInfo();
return netAdapters;
}
}
/// <summary>
/// Refreshes the information about network adapters stored in the netAdapters list.
/// </summary>
public static void RefreshNetAdaptersInfo()
{
if (netAdapters == null) netAdapters = new List<AdapterInfo>();
else netAdapters.Clear();
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in nics)
{
FtpAdapterInfo info = new FtpAdapterInfo(adapter.Description);
netAdapters.Add(info);
}
}
}
}