private String HandleListDevices() { // Refresh _parent.UpdateComputer(); JSONDevicesList devList = new JSONDevicesList(); IEnumerable <IHardware> matchingHardware = _parent.GetComputer().Hardware.Where(h => h.HardwareType == HardwareType.CPU || h.HardwareType == HardwareType.GpuAti || h.HardwareType == HardwareType.GpuNvidia || h.HardwareType == HardwareType.Mainboard); foreach (IHardware h in matchingHardware) { ISensor[] sensorList; HardwareType hardwareType; if (h.HardwareType == HardwareType.Mainboard && h.SubHardware.Length > 0) { sensorList = h.SubHardware[0].Sensors; hardwareType = h.SubHardware[0].HardwareType; } else { sensorList = h.Sensors; hardwareType = h.HardwareType; } IEnumerable <ISensor> matchingSensors = sensorList.Where(s => s.SensorType == SensorType.Clock || s.SensorType == SensorType.Fan || s.SensorType == SensorType.Load || s.SensorType == SensorType.Power || s.SensorType == SensorType.Temperature || s.SensorType == SensorType.Voltage); foreach (ISensor s in matchingSensors) { JSONDeviceCategory cat; switch (hardwareType) { case HardwareType.CPU: cat = JSONDeviceCategory.CPU; break; case HardwareType.GpuAti: cat = JSONDeviceCategory.GPU; break; case HardwareType.GpuNvidia: cat = JSONDeviceCategory.GPU; break; case HardwareType.SuperIO: cat = JSONDeviceCategory.System; break; default: cat = JSONDeviceCategory.Null; break; } devList.AddDevice(cat, s.Name, s.SensorType.ToString()); } } return(JsonConvert.SerializeObject(devList)); }
private String HandleListDevices() { // Refresh _parent.UpdateComputer(); JSONDevicesList devList = new JSONDevicesList(); IEnumerable<IHardware> matchingHardware = _parent.GetComputer().Hardware.Where(h => h.HardwareType == HardwareType.CPU || h.HardwareType == HardwareType.GpuAti || h.HardwareType == HardwareType.GpuNvidia || h.HardwareType == HardwareType.Mainboard); foreach (IHardware h in matchingHardware) { ISensor[] sensorList; HardwareType hardwareType; if (h.HardwareType == HardwareType.Mainboard && h.SubHardware.Length > 0) { sensorList = h.SubHardware[0].Sensors; hardwareType = h.SubHardware[0].HardwareType; } else { sensorList = h.Sensors; hardwareType = h.HardwareType; } IEnumerable<ISensor> matchingSensors = sensorList.Where(s => s.SensorType == SensorType.Clock || s.SensorType == SensorType.Fan || s.SensorType == SensorType.Load || s.SensorType == SensorType.Power || s.SensorType == SensorType.Temperature || s.SensorType == SensorType.Voltage); foreach (ISensor s in matchingSensors) { JSONDeviceCategory cat; switch (hardwareType) { case HardwareType.CPU: cat = JSONDeviceCategory.CPU; break; case HardwareType.GpuAti: cat = JSONDeviceCategory.GPU; break; case HardwareType.GpuNvidia: cat = JSONDeviceCategory.GPU; break; case HardwareType.SuperIO: cat = JSONDeviceCategory.System; break; default: cat = JSONDeviceCategory.Null; break; } devList.AddDevice(cat, s.Name, s.SensorType.ToString()); } } return JsonConvert.SerializeObject(devList); }