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 GetHardware() { Log.Information("Updating computer"); Computer.Accept(HardwareUpdateVisitor); Log.Information("Creating hardware entries"); var hardwareEntries = Computer.Hardware.Select(Hardware.Create); return hardwareEntries; } }