| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System.Net.NetworkInformation;
- namespace QuickIP.Client.Models;
- public sealed class AdapterInfo
- {
- public required string Id { get; set; }
- public required string Name { get; set; }
- public required string Description { get; set; }
- public required string Type { get; set; }
- public required bool IsUp { get; set; }
- public required bool HasLink { get; set; }
- public required int RecommendationScore { get; set; }
- public required string RecommendationLabel { get; set; }
- public required string RecommendationReason { get; set; }
- public string IPv4Address { get; set; } = string.Empty;
- public string ProbeStatus { get; set; } = "未探测";
- public string ProbeReason { get; set; } = "尚未对 169.254.100.2 进行可达性探测。";
- public bool IsReachableToMaintenance { get; set; }
- public string DisplayName => $"{RecommendationLabel} | {Name} | {Type} | IPv4: {(string.IsNullOrWhiteSpace(IPv4Address) ? "无" : IPv4Address)} | {ProbeStatus}";
- public static AdapterInfo FromNetworkInterface(
- NetworkInterface adapter,
- string ipv4Address,
- int recommendationScore,
- string recommendationLabel,
- string recommendationReason)
- {
- return new AdapterInfo
- {
- Id = adapter.Id,
- Name = adapter.Name,
- Description = adapter.Description,
- Type = adapter.NetworkInterfaceType.ToString(),
- IsUp = adapter.OperationalStatus == OperationalStatus.Up,
- HasLink = adapter.OperationalStatus == OperationalStatus.Up,
- RecommendationScore = recommendationScore,
- RecommendationLabel = recommendationLabel,
- RecommendationReason = recommendationReason,
- IPv4Address = ipv4Address,
- };
- }
- }
|