internal T Value <T>() { Symbolics.Expression expression = Symbolics.Parse <T>(Expression); if (expression.Simplify() is not Symbolics.Constant <T> constant) { throw new TowelBugException($"encountered a measurement conversion expression that could not be simplified to a constant: {expression}"); } return(constant.Value); }
internal T Value <T>() { try { Symbolics.Expression expression = Symbolics.Parse <T>(Expression); Symbolics.Constant <T> constant = expression.Simplify() as Symbolics.Constant <T>; return(constant.Value); } catch (Exception exception) { throw new Exception("There is a BUG in " + nameof(Towel) + ". A " + nameof(ConversionFactorAttribute) + " expression could not simplify to a constant.", exception); } }
internal T Value <T>() { Symbolics.Expression expression = Symbolics.Parse <T>(Expression); Symbolics.Constant <T> constant = expression.Simplify() as Symbolics.Constant <T>; return(constant.Value); }