コード例 #1
0
        public NetworkAdapterInfo(PhysicalAddress macAddress)
            : this()
        {
            if (macAddress == null)
            {
                throw new ArgumentNullException(nameof(macAddress));
            }

            var networkAdapter   = DNSHelper.GetNetworkAdapter(macAddress);
            var networkInterface = DNSHelper.GetNetworkInterface(macAddress);

            if (networkAdapter == null || networkInterface == null)
            {
                throw new ArgumentException($"The device '{macAddress} can not be found.");
            }

            this.InitializeNetworkAdapters(networkAdapter, networkInterface);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NetworkAdapterInfo"/> class, from the specified <paramref name="networkAdapter"/> instance.
        /// </summary>
        /// <param name="deviceName">An string value identifing the name of the device of network adapter.</param>
        /// <exception cref="ArgumentNullException">thrown if the <paramref name="deviceName"/> is <c>Null</c> or <c>Blank</c>.</exception>
        /// <exception cref="ArgumentException">thrown if the specified <paramref name="deviceName"/> is does not belong to a matching network device.</exception>
        public NetworkAdapterInfo(string deviceName)
            : this()
        {
            if (string.IsNullOrWhiteSpace(deviceName))
            {
                throw new ArgumentNullException(nameof(deviceName));
            }

            var networkAdapter   = DNSHelper.GetNetworkAdapter(deviceName);
            var networkInterface = DNSHelper.GetNetworkInterface(deviceName);

            if (networkAdapter == null || networkInterface == null)
            {
                throw new ArgumentException($"The device '{deviceName} can not be found.");
            }

            this.InitializeNetworkAdapters(networkAdapter, networkInterface);
        }
コード例 #3
0
ファイル: DNSHelper.cs プロジェクト: priestofpsi/EasyDNS
 internal static bool TryGetNetworkAdapter(PhysicalAddress macAddress, out ManagementObject networkAdapter)
 {
     networkAdapter = DNSHelper.GetNetworkAdapter(macAddress);
     return(networkAdapter != null);
 }
コード例 #4
0
ファイル: DNSHelper.cs プロジェクト: priestofpsi/EasyDNS
 internal static bool TryGetNetworkAdapter(string deviceName, out ManagementObject networkAdapter)
 {
     networkAdapter = DNSHelper.GetNetworkAdapter(deviceName);
     return(networkAdapter != null);
 }