Compare commits
No commits in common. "4a8e1a987b6af0e496199c3ec022d7107985f02e" and "553b5b0ec3e3283471bce016a34555c72b6e298c" have entirely different histories.
4a8e1a987b
...
553b5b0ec3
@ -51,9 +51,6 @@ public static class OsInfo
|
||||
/// </summary>
|
||||
public static List<IOsDriveInfo> Drives { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Сеть
|
||||
/// </summary>
|
||||
public static List<IOsNetInfo> Net { get; set; }
|
||||
|
||||
#region Служебные методы
|
||||
@ -75,8 +72,6 @@ public static class OsInfo
|
||||
/// </summary>
|
||||
/// <returns>Список информации о процессорах</returns>
|
||||
private static List<IOsProcessorInfo> GetProcessors ()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Создаю результирующий список
|
||||
List<IOsProcessorInfo> processorsList = new();
|
||||
@ -104,20 +99,13 @@ public static class OsInfo
|
||||
Manufacturer = collection.Cast<ManagementObject>()
|
||||
.Select(static a => a.Properties["Manufacturer"].Value.ToString()).ElementAtOrDefault(ind),
|
||||
MaxClockSpeed = TypeConverter.StrToInt(collection.Cast<ManagementObject>()
|
||||
.Select(static a =>
|
||||
a.Properties["MaxClockSpeed"].Value.ToString())
|
||||
.ElementAtOrDefault(ind) ??
|
||||
"0"),
|
||||
.Select(static a => a.Properties["MaxClockSpeed"].Value.ToString()).ElementAtOrDefault(ind) ?? "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"),
|
||||
.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")
|
||||
.Select(static a => a.Properties["NumberOfLogicalProcessors"].Value.ToString()).ElementAtOrDefault(ind) ?? "0")
|
||||
};
|
||||
|
||||
//Добавляю в список
|
||||
@ -127,19 +115,12 @@ public static class OsInfo
|
||||
//Возвращаю список
|
||||
return processorsList;
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение общее количество оперативной памяти
|
||||
/// </summary>
|
||||
/// <returns>Список информации о количестве оперативной памяти</returns>
|
||||
private static ulong GetRAMs ()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Создаю классы менеджмента
|
||||
ManagementClass management = new("Win32_ComputerSystem");
|
||||
@ -149,19 +130,12 @@ public static class OsInfo
|
||||
return TypeConverter.StrToUInt64(collection.Cast<ManagementObject>()
|
||||
.Select(static a => a.Properties["TotalPhysicalMemory"].Value.ToString()).FirstOrDefault() ?? "0");
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получает список видеоадаптеров
|
||||
/// </summary>
|
||||
/// <returns>Список информации о видеоадаптерах</returns>
|
||||
private static List<IOsVideoAdapterInfo> GetVideoAdapterInfos ()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Создаю результирующий список
|
||||
List<IOsVideoAdapterInfo> videosList = new();
|
||||
@ -214,19 +188,12 @@ public static class OsInfo
|
||||
//Возвращаю список
|
||||
return videosList;
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получает список дисков
|
||||
/// </summary>
|
||||
/// <returns>Список информации о дисках</returns>
|
||||
private static List<IOsDriveInfo> GetDriveInfos ()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Создаю результат
|
||||
List<IOsDriveInfo> result = new();
|
||||
@ -240,19 +207,12 @@ public static class OsInfo
|
||||
//Вывожу список
|
||||
return result;
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получаю список HDD/SSD дисков
|
||||
/// </summary>
|
||||
/// <returns>Информация обо всех HDD/SSD дисках</returns>
|
||||
private static List<IOsDriveInfo> GetHDDs ()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Создаю результирующий список
|
||||
List<IOsDriveInfo> driveList = new();
|
||||
@ -293,19 +253,12 @@ public static class OsInfo
|
||||
//Возвращаю список
|
||||
return driveList;
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получаю список CD/DVD/BD дисков
|
||||
/// </summary>
|
||||
/// <returns>Информация обо всех CD/DVD/BD дисках</returns>
|
||||
private static List<IOsDriveInfo> GetCDRom ()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Создаю результирующий список
|
||||
List<IOsDriveInfo> driveList = new();
|
||||
@ -346,19 +299,12 @@ public static class OsInfo
|
||||
//Возвращаю список
|
||||
return driveList;
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получаю информацию о сети интернет
|
||||
/// </summary>
|
||||
/// <returns>Информация о сети интернет</returns>
|
||||
private static List<IOsNetInfo> GetNet ()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Создаю результирующий список
|
||||
List<IOsNetInfo> netList = new();
|
||||
@ -371,14 +317,11 @@ public static class OsInfo
|
||||
{
|
||||
Name = adapter.Name,
|
||||
Description = adapter.Description,
|
||||
MacAddress = adapter.OperationalStatus == OperationalStatus.Up
|
||||
? adapter.GetPhysicalAddress().ToString()
|
||||
: null
|
||||
MacAddress = adapter.OperationalStatus == OperationalStatus.Up ? adapter.GetPhysicalAddress().ToString() : null
|
||||
};
|
||||
|
||||
//Получаю IP-адрес
|
||||
foreach (UnicastIPAddressInformation info in adapter.GetIPProperties().UnicastAddresses.Where(
|
||||
static info =>
|
||||
foreach (UnicastIPAddressInformation info in adapter.GetIPProperties().UnicastAddresses.Where(static info =>
|
||||
info.Address.AddressFamily == AddressFamily.InterNetwork && info.IsDnsEligible))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(netInfo.IPAddress))
|
||||
@ -393,10 +336,5 @@ public static class OsInfo
|
||||
//Возвращаю список
|
||||
return netList;
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Version>2023.212.0</Version>
|
||||
<Version>2023.211.0</Version>
|
||||
<Authors>Alexander Babaev</Authors>
|
||||
<Product>ANB Software Components Pack</Product>
|
||||
<Description>Library of some useful functions in C# language.</Description>
|
||||
|
Loading…
x
Reference in New Issue
Block a user