public static Rational GetRational([NotNull] this Directory directory, int tagType) { if (directory.TryGetRational(tagType, out Rational value)) { return(value); } return(ThrowValueNotPossible <Rational>(directory, tagType)); }
private static T?ParseRational <T>(Directory directory, int tag, Func <double, T> convert) where T : struct { if (directory.TryGetRational(tag, out var rational)) { var orig = (rational.Numerator / (double)rational.Denominator); // var boxed = (object) orig; return(convert(orig)); } return(null); }