public static bool TryParse(RpnValueType type, string text, Calculator?calc, [MaybeNullWhen(false)] out Value value) { // NOTE: calc can be null. bool result; switch (type) { case RpnValueType.Binary: BinaryValue?binaryValue; result = BinaryValue.TryParse(text, calc, out binaryValue); value = binaryValue; break; case RpnValueType.Complex: ComplexValue?complexValue; result = ComplexValue.TryParse(text, calc, out complexValue); value = complexValue; break; case RpnValueType.DateTime: DateTimeValue?dateTimeValue; result = DateTimeValue.TryParse(text, out dateTimeValue); value = dateTimeValue; break; case RpnValueType.Double: DoubleValue?doubleValue; result = DoubleValue.TryParse(text, out doubleValue); value = doubleValue; break; case RpnValueType.Fraction: FractionValue?fractionValue; result = FractionValue.TryParse(text, out fractionValue); value = fractionValue; break; case RpnValueType.Integer: IntegerValue?integerValue; result = IntegerValue.TryParse(text, out integerValue); value = integerValue; break; case RpnValueType.TimeSpan: TimeSpanValue?timeSpanValue; result = TimeSpanValue.TryParse(text, out timeSpanValue); value = timeSpanValue; break; default: result = false; value = null; break; } return(result); }
public static bool TryParse(RpnValueType type, string text, out Value?value) { return(TryParse(type, text, null, out value)); }