internal DisplayUnits( DisplayValue displayValue, Unit source, Unit[] list ) { Contract.Requires <ArgumentNullException>(list != null); Contract.Requires <ArgumentException>(list.Length > 0); Contract.Requires <ArgumentException>(list.All(unit => UnitConverter.IsConvertible(source, unit))); Source = source; List = list; _displayValue = displayValue; }
void AddDisplayValues() { Resistance = new DisplayValue ( () => Voltmeter.Readings.Resistance, Units.Resistance.Ohm, Units.Resistance.All ); Voltage = new DisplayValue ( () => Voltmeter.Readings.Voltage, Units.Voltage.Volts, Units.Voltage.All ); Current = new DisplayValue ( () => Voltmeter.Readings.Current, Units.Current.Ampers, Units.Current.All ); Power = new DisplayValue ( () => Voltmeter.Readings.Power, Units.Power.Watts, Units.Power.All ); Energy = new DisplayValue ( () => Voltmeter.Readings.Energy, Units.Energy.WattSecond, Units.Energy.All ); NoiseThreshold = new DisplayValue ( () => Voltmeter.Readings.NoiseThreshold, Units.Voltage.Volts, Units.Voltage.All.ToArray(), // use list copy to avoid side-effects with Voltage (while DataBinding) minSourceValue: 0.0, maxSourceValue: DeviceConstants.MaxMeasuredVoltage ); }
internal DisplayUnits( DisplayValue displayValue, Unit source, Unit[] list ) { Contract.Requires<ArgumentNullException>(list != null); Contract.Requires<ArgumentException>(list.Length > 0); Contract.Requires<ArgumentException>(list.All(unit => UnitConverter.IsConvertible(source, unit))); Source = source; List = list; _displayValue = displayValue; }