/// <summary>
        /// Detects a connected <see cref="NetworkInterface"/> adapter.
        /// </summary>
        /// <returns>The first connected wifi adapter found, or <see langworg="null"/>.</returns>
        protected override NetworkInterface DetectConnectedAdapter()
        {
            List <string> wifiAdapters = WifiInterfaceEnumerator.EnumerateWirelessAdapters();

            foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
            {
                if ((adapter.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || wifiAdapters.Contains(adapter.Id)) &&
                    adapter.OperationalStatus == OperationalStatus.Up)
                {
                    return(adapter);
                }
            }
            return(null);
        }
Exemple #2
0
        /// <summary>
        /// Detects a connected <see cref="NetworkInterface"/> adapter.
        /// Overriden to only detect wired adapters.
        /// </summary>
        /// <returns>The first connected <see cref="NetworkInterface"/> found, or <see langworg="null"/>.</returns>
        protected override NetworkInterface DetectConnectedAdapter()
        {
            List <string> wifiAdapters = WifiInterfaceEnumerator.EnumerateWirelessAdapters();

            foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
            {
                if ((adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet ||
                     adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet3Megabit ||
                     adapter.NetworkInterfaceType == NetworkInterfaceType.FastEthernetFx ||
                     adapter.NetworkInterfaceType == NetworkInterfaceType.FastEthernetT ||
                     adapter.NetworkInterfaceType == NetworkInterfaceType.GigabitEthernet) &&
                    wifiAdapters.Contains(adapter.Id) == false &&
                    adapter.OperationalStatus == OperationalStatus.Up)
                {
                    return(adapter);
                }
            }

            return(null);
        }