Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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();
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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);
        }