public void ItParsesScientificNotationCorrectly(string input, double value, Type type) { var result = MeasurementParser.Parse <IMeasurement>(input); Assert.That(result.Value, Is.EqualTo(value)); Assert.That(result.GetType(), Is.EqualTo(type)); }
public void ItParsesTemperatureMeasurementsCorrectly(string input, double value, Type type) { var result = MeasurementParser.Parse <ITemperature>(input); Assert.That(result.Value, Is.EqualTo(value)); Assert.That(result.GetType(), Is.EqualTo(type)); }
public static void Main(string[] args) { MeasurementParser <Density> parser = new MeasurementParser <Density>(Density.Provider); Console.WriteLine(parser.Parse("8 * lb / [(3.1 m)**2 * ft]")); Console.Read(); }
public static TMeasurement GetAttributeMeasurementValue <TMeasurement>(this XElement element, string attribute) where TMeasurement : IMeasurement { var valueString = element.GetAttributeStringValue("Value"); if (valueString == null) { return(default(TMeasurement)); } return(MeasurementParser.Parse <TMeasurement>(valueString)); }
public override TMeasurement GetValue() { var dataEntry = GetDataEntry(); if (dataEntry == null) { return(null); } var number = dataEntry.DecimalValue.Value; var units = dataEntry.Units; if (number == 0 && units == string.Empty) { return(null); } var result = MeasurementParser.Parse <TMeasurement>((double)number, units); return(result); }