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);
 }
示例#2
0
 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);
     }
 }
示例#3
0
 internal T Value <T>()
 {
     Symbolics.Expression   expression = Symbolics.Parse <T>(Expression);
     Symbolics.Constant <T> constant   = expression.Simplify() as Symbolics.Constant <T>;
     return(constant.Value);
 }