Example #1
0
        public static bool TryParse(string value, out ValueUnit valueUnit)
        {
            if (decimal.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
                                 CultureInfo.InvariantCulture,
                                 out var result))
            {
                valueUnit = new ValueUnit(result);
                return(true);
            }

            valueUnit = null;
            return(false);
        }
Example #2
0
        private static bool TryParseValueUnit(string value, out IUnit result)
        {
            if (ValueUnit.TryParse(value, out var valueUnit))
            {
                result = valueUnit;
                return true;
            }

            if (TryParse(value, out var expressionUnit))
            {
                result = expressionUnit;
                return true;
            }

            result = null;
            return false;
        }