@@ -51,6 +51,9 @@ public static class OsInfo
/// </summary>
/// </summary>
public static List < IOsDriveInfo > Drives { get ; set ; }
public static List < IOsDriveInfo > Drives { get ; set ; }
/// <summary>
/// Сеть
/// </summary>
public static List < IOsNetInfo > Net { get ; set ; }
public static List < IOsNetInfo > Net { get ; set ; }
#region С л у ж е б н ы е м е т о д ы
#region С л у ж е б н ы е м е т о д ы
@@ -73,47 +76,61 @@ public static class OsInfo
/// <returns>Список информации о процессорах</returns>
/// <returns>Список информации о процессорах</returns>
private static List < IOsProcessorInfo > GetProcessors ( )
private static List < IOsProcessorInfo > GetProcessors ( )
{
{
//Создаю результирующий список
try
List < IOsProcessorInfo > processorsList = new ( ) ;
//Создаю классы менеджмента
ManagementClass management = new ( "Win32_Processor" ) ;
ManagementObjectCollection collection = management . GetInstances ( ) ;
//Получаю число процессоров
int processorsCount = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "ProcessorId" ] . Value . ToString ( ) ) . Count ( ) ;
//Перебираю массив данных
for ( int ind = 0 ; ind < processorsCount ; ind + + )
{
{
//Создаю элемент информации о процессоре
//Создаю результирующий список
OsProcessorInfo processor = new ( )
List < I OsProcessorInfo> processorsList = new ( ) ;
//Создаю классы менеджмента
ManagementClass management = new ( "Win32_Processor" ) ;
ManagementObjectCollection collection = management . GetInstances ( ) ;
//Получаю число процессоров
int processorsCount = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "ProcessorId" ] . Value . ToString ( ) ) . Count ( ) ;
//Перебираю массив данных
for ( int ind = 0 ; ind < processorsCount ; ind + + )
{
{
Caption = collection . Cast < ManagementObject > ( )
//Создаю элемент информации о процессоре
. Select ( static a = > a . Properties [ "Caption" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
OsProcessorInfo processor = new ( )
Description = collection . Cast < ManagementObject > ( )
{
. Select ( static a = > a . Properties [ "Description" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
Caption = collection . Cast < ManagementObject > ( )
DeviceId = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Caption" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
Description = collection . Cast < ManagementObject > ( )
Manufacturer = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Description" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "Manufacturer" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
DeviceId = collection . Cast < ManagementObject > ( )
MaxClockSpeed = TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "MaxClockSpeed" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ? ? "0" ) ,
Manufacturer = collection . Cast < ManagementObject > ( )
Name = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Manufacturer" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "Name" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
MaxClockSpeed = TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
NumberOfCores = TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
. Select ( static a = >
. Select ( static a = > a . Properties [ "NumberOfCores " ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ? ? "0" ) ,
a . Properties [ "MaxClockSpeed " ] . Value . ToString ( ) )
NumberOfLogicalProcessors = TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
. ElementAtOrDefault ( ind ) ? ?
. Select ( static a = > a . Properties [ "NumberOfLogicalProcessors" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ? ? "0" )
"0" ) ,
} ;
Name = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Name" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
NumberOfCores = TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
. Select ( static a = >
a . Properties [ "NumberOfCores" ] . Value . ToString ( ) )
. ElementAtOrDefault ( ind ) ? ?
"0" ) ,
NumberOfLogicalProcessors = TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "NumberOfLogicalProcessors" ] . Value . ToString ( ) )
. ElementAtOrDefault ( ind ) ? ? "0" )
} ;
//Добавляю в список
//Добавляю в список
processorsList . Add ( processor ) ;
processorsList . Add ( processor ) ;
}
//Возвращаю список
return processorsList ;
}
catch ( NullReferenceException )
{
return new ( ) ;
}
}
//Возвращаю список
return processorsList ;
}
}
/// <summary>
/// <summary>
@@ -122,13 +139,20 @@ public static class OsInfo
/// <returns>Список информации о количестве оперативной памяти</returns>
/// <returns>Список информации о количестве оперативной памяти</returns>
private static ulong GetRAMs ( )
private static ulong GetRAMs ( )
{
{
//Создаю классы менеджмента
try
ManagementClass management = new ( "Win32_ComputerSystem" ) ;
{
ManagementObjectCollection collection = management . GetInstances ( ) ;
//Создаю классы менеджмента
ManagementClass management = new ( "Win32_ComputerSystem" ) ;
ManagementObjectCollection collection = management . GetInstances ( ) ;
//Получаю результат
//Получаю результат
return TypeConverter . StrToUInt64 ( collection . Cast < ManagementObject > ( )
return TypeConverter . StrToUInt64 ( collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "TotalPhysicalMemory" ] . Value . ToString ( ) ) . FirstOrDefault ( ) ? ? "0" ) ;
. Select ( static a = > a . Properties [ "TotalPhysicalMemory" ] . Value . ToString ( ) ) . FirstOrDefault ( ) ? ? "0" ) ;
}
catch ( NullReferenceException )
{
return 0 ;
}
}
}
/// <summary>
/// <summary>
@@ -137,56 +161,63 @@ public static class OsInfo
/// <returns>Список информации о видеоадаптерах</returns>
/// <returns>Список информации о видеоадаптерах</returns>
private static List < IOsVideoAdapterInfo > GetVideoAdapterInfos ( )
private static List < IOsVideoAdapterInfo > GetVideoAdapterInfos ( )
{
{
//Создаю результирующий список
try
List < IOsVideoAdapterInfo > videosList = new ( ) ;
//Создаю классы менеджмента
ManagementClass management = new ( "Win32_VideoController" ) ;
ManagementObjectCollection collection = management . GetInstances ( ) ;
//Получаю число адаптеров
int count = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . Count ( ) ;
//Перебираю массив данных
for ( int ind = 0 ; ind < count ; ind + + )
{
{
//Создаю элемент информации о б адаптере
//Создаю результирующий список
OsVideoAdapterInfo adapter = new ( )
List < I OsVideoAdapterInfo> videosList = new ( ) ;
//Создаю классы менеджмента
ManagementClass management = new ( "Win32_VideoController" ) ;
ManagementObjectCollection collection = management . GetInstances ( ) ;
//Получаю число адаптеров
int count = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . Count ( ) ;
//Перебираю массив данных
for ( int ind = 0 ; ind < count ; ind + + )
{
{
Caption = collection . Cast < ManagementObject > ( )
//Создаю элемент информации о б адаптере
. Select ( static a = > a . Properties [ "Caption" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
OsVideoAdapterInfo adapter = new ( )
Description = collection . Cast < ManagementObject > ( )
{
. Select ( static a = > a . Properties [ "Description" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
Caption = collection . Cast < ManagementObject > ( )
DeviceId = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Caption" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
Description = collection . Cast < ManagementObject > ( )
AdapterRAM = TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Description" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "AdapterRAM" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ? ? "0" ) ,
DeviceId = collection . Cast < ManagementObject > ( )
DriverDate = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "DriverDate" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
AdapterRAM = TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
Name = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "AdapterRAM" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ? ? "0" ) ,
. Select ( static a = > a . Properties [ "Name" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
DriverDate = collection . Cast < ManagementObject > ( )
CurrentResolution = ( TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "DriverDate" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "CurrentHorizontalResolution" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ? ? "0" ) ,
Name = collection . Cast < ManagementObject > ( )
TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Name" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "CurrentVerticalResolution" ] . Value . ToString ( ) )
CurrentResolution = ( TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
. ElementAtOrDefault ( ind ) ? ? "0" ) ) ,
. Select ( static a = > a . Properties [ "CurrentHorizontalResolution" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ? ? "0" ) ,
SystemName = collection . Cast < ManagementObject > ( )
TypeConverter . StrToInt ( collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "SystemName " ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "CurrentVerticalResolution " ] . Value . ToString ( ) )
DriverVersion = collection . Cast < ManagementObject > ( )
. ElementAtOrDefault ( ind ) ? ? "0" ) ) ,
. Select ( static a = > a . Properties [ "DriverVersion" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
SystemName = collection . Cast < ManagementObject > ( )
InstalledDisplayDrivers = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "SystemName" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "InstalledDisplayDrivers" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
DriverVersion = collection . Cast < ManagementObject > ( )
VideoProcessor = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "DriverVersion" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "VideoProcessor" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind )
InstalledDisplayDrivers = collection . Cast < ManagementObject > ( )
} ;
. Select ( static a = > a . Properties [ "InstalledDisplayDrivers" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
VideoProcessor = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "VideoProcessor" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind )
} ;
//Добавляю в список
//Добавляю в список
videosList . Add ( adapter ) ;
videosList . Add ( adapter ) ;
}
//Возвращаю список
return videosList ;
}
catch ( NullReferenceException )
{
return new ( ) ;
}
}
//Возвращаю список
return videosList ;
}
}
/// <summary>
/// <summary>
@@ -195,17 +226,24 @@ public static class OsInfo
/// <returns>Список информации о дисках</returns>
/// <returns>Список информации о дисках</returns>
private static List < IOsDriveInfo > GetDriveInfos ( )
private static List < IOsDriveInfo > GetDriveInfos ( )
{
{
//Создаю результат
try
List < IOsDriveInfo > result = new ( ) ;
{
//Создаю результат
List < IOsDriveInfo > result = new ( ) ;
//Добавление всех HDD/SSD дисков
//Добавление всех HDD/SSD дисков
result . AddRange ( GetHDDs ( ) ) ;
result . AddRange ( GetHDDs ( ) ) ;
//Добавление всех CD/DVD/BD дисков
//Добавление всех CD/DVD/BD дисков
result . AddRange ( GetCDRom ( ) ) ;
result . AddRange ( GetCDRom ( ) ) ;
//Вывожу список
//Вывожу список
return result ;
return result ;
}
catch ( NullReferenceException )
{
return new ( ) ;
}
}
}
/// <summary>
/// <summary>
@@ -214,44 +252,51 @@ public static class OsInfo
/// <returns>Информация о б о всех HDD/SSD дисках</returns>
/// <returns>Информация о б о всех HDD/SSD дисках</returns>
private static List < IOsDriveInfo > GetHDDs ( )
private static List < IOsDriveInfo > GetHDDs ( )
{
{
//Создаю результирующий список
try
List < IOsDriveInfo > driveList = new ( ) ;
//Создаю классы менеджмента
ManagementClass management = new ( "Win32_DiskDrive" ) ;
ManagementObjectCollection collection = management . GetInstances ( ) ;
//Получаю число адаптеров
int count = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . Count ( ) ;
//Перебираю массив данных
for ( int ind = 0 ; ind < count ; ind + + )
{
{
//Создаю элемент информации о б адаптере
//Создаю результирующий список
OsDriveInfo drive = new ( )
List < I OsDriveInfo> driveList = new ( ) ;
//Создаю классы менеджмента
ManagementClass management = new ( "Win32_DiskDrive" ) ;
ManagementObjectCollection collection = management . GetInstances ( ) ;
//Получаю число адаптеров
int count = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . Count ( ) ;
//Перебираю массив данных
for ( int ind = 0 ; ind < count ; ind + + )
{
{
Type = EDriveType . DtHardDisc ,
//Создаю элемент информации о б адаптере
Caption = collection . Cast < ManagementObject > ( )
OsDriveInfo drive = new ( )
. Select ( static a = > a . Properties [ "Caption" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
{
Description = collection . Cast < ManagementObject > ( )
Type = EDriveType . DtHardDisc ,
. Select ( static a = > a . Properties [ "Description" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
Caption = collection . Cast < ManagementObject > ( )
DeviceId = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Caption" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
Description = collection . Cast < ManagementObject > ( )
Name = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Description" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "Name" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
DeviceId = collection . Cast < ManagementObject > ( )
TotalSize = TypeConverter . StrToUInt64 ( collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "Size" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ? ? "0" ) ,
Name = collection . Cast < ManagementObject > ( )
Model = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Name" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "Model" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind )
TotalSize = TypeConverter . StrToUInt64 ( collection . Cast < ManagementObject > ( )
} ;
. Select ( static a = > a . Properties [ "Size" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ? ? "0" ) ,
Model = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Model" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind )
} ;
//Добавляю в список
//Добавляю в список
driveList . Add ( drive ) ;
driveList . Add ( drive ) ;
}
//Возвращаю список
return driveList ;
}
catch ( NullReferenceException )
{
return new ( ) ;
}
}
//Возвращаю список
return driveList ;
}
}
/// <summary>
/// <summary>
@@ -260,44 +305,51 @@ public static class OsInfo
/// <returns>Информация о б о всех CD/DVD/BD дисках</returns>
/// <returns>Информация о б о всех CD/DVD/BD дисках</returns>
private static List < IOsDriveInfo > GetCDRom ( )
private static List < IOsDriveInfo > GetCDRom ( )
{
{
//Создаю результирующий список
try
List < IOsDriveInfo > driveList = new ( ) ;
//Создаю классы менеджмента
ManagementClass management = new ( "Win32_CDROMDrive" ) ;
ManagementObjectCollection collection = management . GetInstances ( ) ;
//Получаю число адаптеров
int count = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . Count ( ) ;
//Перебираю массив данных
for ( int ind = 0 ; ind < count ; ind + + )
{
{
//Создаю элемент информации о б адаптере
//Создаю результирующий список
OsDriveInfo drive = new ( )
List < I OsDriveInfo> driveList = new ( ) ;
//Создаю классы менеджмента
ManagementClass management = new ( "Win32_CDROMDrive" ) ;
ManagementObjectCollection collection = management . GetInstances ( ) ;
//Получаю число адаптеров
int count = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . Count ( ) ;
//Перебираю массив данных
for ( int ind = 0 ; ind < count ; ind + + )
{
{
Type = EDriveType . DtCDRom ,
//Создаю элемент информации о б адаптере
Caption = collection . Cast < ManagementObject > ( )
OsDriveInfo drive = new ( )
. Select ( static a = > a . Properties [ "Caption" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
{
Description = collection . Cast < ManagementObject > ( )
Type = EDriveType . DtCDRom ,
. Select ( static a = > a . Properties [ "Description" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
Caption = collection . Cast < ManagementObject > ( )
DeviceId = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Caption" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
Description = collection . Cast < ManagementObject > ( )
Name = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Description" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "Name" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
DeviceId = collection . Cast < ManagementObject > ( )
//Ставится 0, чтобы не проверять корректность загрузки и читаемость диска, а также избежать удлинения получения информации
. Select ( static a = > a . Properties [ "DeviceID" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
TotalSize = 0 ,
Name = collection . Cast < ManagementObject > ( )
Model = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Name" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind ) ,
. Select ( static a = > a . Properties [ "Manufacturer" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind )
//Ставится 0, чтобы не проверять корректность загрузки и читаемость диска, а также избежать удлинения получения информации
} ;
TotalSize = 0 ,
Model = collection . Cast < ManagementObject > ( )
. Select ( static a = > a . Properties [ "Manufacturer" ] . Value . ToString ( ) ) . ElementAtOrDefault ( ind )
} ;
//Добавляю в список
//Добавляю в список
driveList . Add ( drive ) ;
driveList . Add ( drive ) ;
}
//Возвращаю список
return driveList ;
}
catch ( NullReferenceException )
{
return new ( ) ;
}
}
//Возвращаю список
return driveList ;
}
}
/// <summary>
/// <summary>
@@ -306,35 +358,45 @@ public static class OsInfo
/// <returns>Информация о сети интернет</returns>
/// <returns>Информация о сети интернет</returns>
private static List < IOsNetInfo > GetNet ( )
private static List < IOsNetInfo > GetNet ( )
{
{
//Создаю результирующий список
try
List < IOsNetInfo > netList = new ( ) ;
//Получаю информацию о всех сетевых интерфейсах
foreach ( NetworkInterface adapter in NetworkInterface . GetAllNetworkInterfaces ( ) )
{
{
//Создаю элемент
//Создаю результирующий список
OsNetInfo netInfo = new ( )
List < I OsNetInfo> netList = new ( ) ;
{
Name = adapter . Name ,
Description = adapter . Description ,
MacAddress = adapter . OperationalStatus = = OperationalStatus . Up ? adapter . GetPhysicalAddress ( ) . ToString ( ) : null
} ;
//Получаю IP-адрес
//Получаю информацию о всех сетевых интерфейсах
foreach ( UnicastIPAddressInformation info in adapter . GetIPProperties ( ) . UnicastAddresses . Where ( static info = >
foreach ( NetworkInterface adapter in NetworkInterface . GetAllNetworkInterfaces ( ) )
info . Address . AddressFamily = = AddressFamily . InterNetwork & & info . IsDnsEligible ) )
{
{
if ( ! string . IsNullOrWhiteSpace ( netInfo . IPAddress ) )
//Создаю элемент
n etInfo . IPAddress + = ";" ;
OsN etInfo netInfo = new ( )
netInfo . IPAddress + = info . Address . ToString ( ) ;
{
Name = adapter . Name ,
Description = adapter . Description ,
MacAddress = adapter . OperationalStatus = = OperationalStatus . Up
? adapter . GetPhysicalAddress ( ) . ToString ( )
: null
} ;
//Получаю IP-адрес
foreach ( UnicastIPAddressInformation info in adapter . GetIPProperties ( ) . UnicastAddresses . Where (
static info = >
info . Address . AddressFamily = = AddressFamily . InterNetwork & & info . IsDnsEligible ) )
{
if ( ! string . IsNullOrWhiteSpace ( netInfo . IPAddress ) )
netInfo . IPAddress + = ";" ;
netInfo . IPAddress + = info . Address . ToString ( ) ;
}
//Добавляю адаптер
netList . Add ( netInfo ) ;
}
}
//Добавляю адаптер
//Возвращаю список
netList. Add ( netInfo ) ;
return netList ;
}
catch ( NullReferenceException )
{
return new ( ) ;
}
}
//Возвращаю список
return netList ;
}
}
#endregion
#endregion
}
}