public static TRet Calculate(string text, string name, Func <ROMol, TRet> calculator) { if (text == null) { throw new ArgumentNullException(nameof(text)); } var key = new Tuple <string, string>(name, text); var nReturnValue = ValueCache.GetOrAdd(key, tuple => { var mol = Parse(text); return(calculator(mol)); }); return(nReturnValue); }