コード例 #1
0
        public TQuantity ParseExact(string text, string format, IFormatProvider formatProvider)
        {
            if (!TryExtractParts(text, format, formatProvider, out string valueStr, out string valueFormat, out string unitStr, out string unitFormat))
            {
                throw Error.IncorrectFormat($"'{text}' is not a correct {typeof(TQuantity)}.");
            }

            var value = _valueParser.ParseExact(valueStr, valueFormat, formatProvider);
            var unit  = _unitParser.ParseExact(unitStr, unitFormat, formatProvider);

            return(_quantityFactory.Create(value, unit));
        }
コード例 #2
0
 public Weight ParseExact(string value, string format, IFormatProvider formatProvider) =>
 _formattedParser.ParseExact(value, format, formatProvider);