public static RadialVelocityValue StrToRadialVelocity(string value) { var ss = _doubleRege.Split(value).Where(t => { var s = t.Trim(); return(!(s == "," || s == "" || s == ",")); }); string num = ""; string unit = ""; foreach (var s in ss) { if (_doubleRege.IsMatch(s)) { num = s; continue; } if (_unitRegex.IsMatch(s)) { unit = s; continue; } } RateUnits units = RateUnits.kilometer; if (unit.ToLower() == "k" || unit.ToLower() == "km" || unit.ToLower() == "km/" || unit.ToLower() == "km/h") { units = RateUnits.kilometer; } if (double.TryParse(num, out double dd)) { return(new RadialVelocityValue(dd, units)); } return(null); }
public RadialVelocityValue(double value, RateUnits units = RateUnits.kilometer) { _value = value; _units = RateUnits.kilometer; }