/// <summary> /// Gets a key from the <paramref name="parameters"/> with <paramref name="prefix"/> or throws <see cref="MissingKeyInParametersException"/>. /// </summary> /// <param name="converter">A key-parameters converter.</param> /// <param name="parameters">A collection of parameters.</param> /// <param name="prefix">A values prefix for <paramref name="parameters"/>.</param> /// <returns>A key from the <paramref name="parameters"/> or throws <see cref="MissingKeyInParametersException"/>.</returns> public static IKey Get(this KeyToParametersConverter converter, IReadOnlyKeyValueCollection parameters, string prefix) { Ensure.NotNull(converter, "converter"); IKey key; if (converter.TryGet(parameters, prefix, out key)) { return(key); } throw new MissingKeyInParametersException(); }
/// <summary> /// Gets a key from the <paramref name="parameters"/> or throws <see cref="MissingKeyInParametersException"/>. /// </summary> /// <typeparam name="TKey">A type of the key.</typeparam> /// <param name="converter">A key-parameters converter.</param> /// <param name="parameters">A collection of parameters.</param> /// <returns>A key from the <paramref name="parameters"/> or throws <see cref="MissingKeyInParametersException"/>.</returns> public static TKey Get <TKey>(this KeyToParametersConverter converter, IReadOnlyKeyValueCollection parameters) where TKey : IKey { Ensure.NotNull(converter, "converter"); TKey key; if (converter.TryGet(parameters, out key)) { return(key); } throw new MissingKeyInParametersException(); }