Exemple #1
0
        public async Task <decimal> ConvertValue(decimal input, Unit from, Unit to)
        {
            string expression = await repository.GetConversionExpression(from, to);

            var    inter            = new Interpreter(InterpreterOptions.PrimitiveTypes);
            Lambda parsedExpression = inter.Parse(expression, new Parameter("x", typeof(decimal)));
            var    result           = parsedExpression.Invoke(input) as decimal?;

            return(result.Value);
        }