private T GetOrAdd <T>(ILookupKey <T> lookupKey, T value) { if (hashtable.ContainsKey(lookupKey)) { return((T)hashtable[lookupKey]); } hashtable[lookupKey] = value; return(value); }
private T GetOrAdd <T>(ILookupKey <T> lookupKey, Func <T> factory) { if (hashtable.ContainsKey(lookupKey)) { return((T)hashtable[lookupKey]); } T value = default(T); try { value = factory(); } catch { return(value); } hashtable[lookupKey] = value; return(value); }