public Mainboard(SMBIOS smbios, ISettings settings) { this.settings = settings; this.smbios = smbios; Manufacturer manufacturer = smbios.Board == null ? Manufacturer.Unknown : Identification.GetManufacturer(smbios.Board.ManufacturerName); Model model = smbios.Board == null ? Model.Unknown : Identification.GetModel(smbios.Board.ProductName); if (smbios.Board != null) { if (!string.IsNullOrEmpty(smbios.Board.ProductName)) { if (manufacturer == Manufacturer.Unknown) { this.name = smbios.Board.ProductName; } else { this.name = manufacturer + " " + smbios.Board.ProductName; } } else { this.name = manufacturer.ToString(); } } else { this.name = Manufacturer.Unknown.ToString(); } this.customName = settings.GetValue( new Identifier(Identifier, "name").ToString(), name); ISuperIO[] superIO; int p = (int)Environment.OSVersion.Platform; if ((p == 4) || (p == 128)) { this.lmSensors = new LMSensors(); superIO = lmSensors.SuperIO; } else { this.lpcio = new LPCIO(); superIO = lpcio.SuperIO; } superIOHardware = new Hardware[superIO.Length]; for (int i = 0; i < superIO.Length; i++) { superIOHardware[i] = new SuperIOHardware(this, superIO[i], manufacturer, model, settings); } }
/// <summary> /// Creates motherboard instance by retrieving information from <see cref="LibreHardwareMonitor.Hardware.SMBios"/> and creates a new <see cref="SubHardware"/> based on data from <see cref="LpcIO"/> and <see cref="EmbeddedController"/>. /// </summary> /// <param name="smBios"><see cref="LibreHardwareMonitor.Hardware.SMBios"/> table containing motherboard data.</param> /// <param name="settings">Additional settings passed by <see cref="IComputer"/>.</param> public Motherboard(SMBios smBios, ISettings settings) { IReadOnlyList <ISuperIO> superIO; _settings = settings; SMBios = smBios; Manufacturer manufacturer = smBios.Board == null ? Manufacturer.Unknown : Identification.GetManufacturer(smBios.Board.ManufacturerName); Model model = smBios.Board == null ? Model.Unknown : Identification.GetModel(smBios.Board.ProductName); if (smBios.Board != null) { if (!string.IsNullOrEmpty(smBios.Board.ProductName)) { if (manufacturer == Manufacturer.Unknown) { _name = smBios.Board.ProductName; } else { _name = manufacturer + " " + smBios.Board.ProductName; } } else { _name = manufacturer.ToString(); } } else { _name = Manufacturer.Unknown.ToString(); } _customName = settings.GetValue(new Identifier(Identifier, "name").ToString(), _name); if (OperatingSystem.IsUnix) { _lmSensors = new LMSensors(); superIO = _lmSensors.SuperIO; } else { _lpcIO = new LpcIO(); superIO = _lpcIO.SuperIO; } EmbeddedController embeddedController = EmbeddedController.Create(model, settings); SubHardware = new IHardware[superIO.Count + (embeddedController != null ? 1 : 0)]; for (int i = 0; i < superIO.Count; i++) { SubHardware[i] = new SuperIOHardware(this, superIO[i], manufacturer, model, settings); } if (embeddedController != null) { SubHardware[superIO.Count] = embeddedController; } }