All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 54s
50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using LibreHardwareMonitor.Hardware;
|
|
using Serilog;
|
|
|
|
namespace HardwareMonitorStatusWindow.Service;
|
|
|
|
public class HardwareMonitorService : IHardwareMonitorService
|
|
{
|
|
public const string ScheduledTaskName = "HardwareMonitorService";
|
|
public const string PipeName = "HardwareMonitorService";
|
|
|
|
private static readonly Computer Computer;
|
|
private static readonly HardwareUpdateVisitor HardwareUpdateVisitor;
|
|
|
|
static HardwareMonitorService()
|
|
{
|
|
Log.Information("Creating computer");
|
|
|
|
Computer = new Computer
|
|
{
|
|
IsCpuEnabled = true,
|
|
IsGpuEnabled = true,
|
|
IsMemoryEnabled = true,
|
|
IsMotherboardEnabled = true,
|
|
IsControllerEnabled = true,
|
|
IsNetworkEnabled = true,
|
|
IsStorageEnabled = true,
|
|
IsBatteryEnabled = true,
|
|
IsPsuEnabled = true
|
|
};
|
|
|
|
Log.Information("Opening computer");
|
|
|
|
Computer.Open();
|
|
|
|
HardwareUpdateVisitor = new HardwareUpdateVisitor();
|
|
}
|
|
|
|
public IEnumerable<Hardware> GetHardware()
|
|
{
|
|
Log.Information("Updating computer");
|
|
|
|
Computer.Accept(HardwareUpdateVisitor);
|
|
|
|
Log.Information("Creating hardware entries");
|
|
|
|
var hardwareEntries = Computer.Hardware.Select(Hardware.Create);
|
|
|
|
return hardwareEntries;
|
|
}
|
|
} |