public sSystemMetric(SystemMetricTypes type, MetricUnits unit, long val) { _unit = unit; _type = type; _val = val; _additional = null; }
public sSystemMetric(SystemMetricTypes type, MetricUnits unit, long val, string additional) { _unit = unit; _type = type; _val = val; _additional = additional; if (_additional.Length > 20) { _additional = _additional.Substring(0, 17) + "..."; } }
public static object GetMetric(SystemMetricTypes metricType, out Type valueType) { switch (metricType) { case SystemMetricTypes.StartupType: valueType = typeof(WindowsStartupTypes); break; case SystemMetricTypes.IsWindowsStarterEdition: case SystemMetricTypes.IsWindowsMediaCenterEdition: case SystemMetricTypes.IsSystemDocked: case SystemMetricTypes.IsTablePC: case SystemMetricTypes.IsRemoteSession: case SystemMetricTypes.IsShuttingDown: case SystemMetricTypes.IsSlowProcessor: valueType = typeof(bool); break; case SystemMetricTypes.Digitizers: valueType = typeof(Digitizers); break; case SystemMetricTypes.MonitorCount: valueType = typeof(int); break; default: throw new ArgumentOutOfRangeException(nameof(metricType), metricType, null); } var metric = NativeMethods.GetSystemMetrics((int)metricType); return(valueType.IsEnum ? Enum.Parse(valueType, metric.ToString()) : metric.GetType() != valueType?Convert.ChangeType(metric, valueType) : metric); }
public List<sSystemMetric> GetValues(SystemMetricTypes[] types) { Monitor.Enter(_lock); List<sSystemMetric> ret = new List<sSystemMetric>(); foreach (SystemMetricTypes type in types) { if (_values.ContainsKey(type)) { if (_values[type] is List<sSystemMetric>) ret.AddRange((List<sSystemMetric>)_values[type]); else if (_values[type] is sSystemMetric) ret.Add((sSystemMetric)_values[type]); } } Monitor.Exit(_lock); return ret; }
public sSystemMetric(SystemMetricTypes type, MetricUnits unit, decimal val, string additional) : this(type, unit, (long)Math.Floor(val), additional) { }
public sSystemMetric(SystemMetricTypes type, MetricUnits unit, float val, string additional) : this(type, unit, (decimal)val, additional) { }
public sSystemMetric(SystemMetricTypes type, MetricUnits unit, decimal val) : this(type, unit, (long)Math.Floor(val)) { }
public sSystemMetric(SystemMetricTypes type, MetricUnits unit, float val) : this(type, unit, (decimal)val) { }
public sSystemMetric(SystemMetricTypes type, MetricUnits unit, decimal val, string additional): this(type,unit,(long)Math.Floor(val),additional) { }
public sSystemMetric(SystemMetricTypes type, MetricUnits unit, float val,string additional) : this(type, unit, (decimal)val,additional) { }
public sSystemMetric(SystemMetricTypes type, MetricUnits unit, long val,string additional) { _unit = unit; _type = type; _val = val; _additional = additional; if (_additional.Length > 20) _additional = _additional.Substring(0, 17) + "..."; }
public sSystemMetric(SystemMetricTypes type, MetricUnits unit, decimal val) : this(type,unit,(long)Math.Floor(val)) { }