/// <inheritdoc/> public bool TryGetValue <TResult>(out TResult value) where TResult : V { if (_dictionary.TryGetValue(typeof(TResult), out var result)) { value = (TResult)result; return(true); } value = default; return(false); }
/// <inheritdoc/> public TResult GetValue <TResult>() where TResult : V { try { if (!_dictionary.TryGetValue(typeof(TResult), out V result)) { var args = new TypeNotFoundEventArgs <V>(typeof(TResult)); TypeNotFound?.Invoke(this, args); if (args.Value is TResult newResult) { Add(newResult); return(newResult); } } return((TResult)result); } catch (KeyNotFoundException ex) { throw new TypeNotFoundException(Properties.Resources.TypeDictionary_TypeNotFound.FormatString(typeof(TResult).FullName), ex); } }