public bool HasValueFor(ConfigurationKeyBase key) { if (key == null) { return(false); } foreach (var configuration in _configurations) { if (configuration.HasValueFor(key)) { return(true); } } return(false); }
/// <summary> /// Returns the value for the given configuration key. /// </summary> /// <typeparam name="T">The type of the return value.</typeparam> /// <param name="key">The configuration key.</param> /// <returns> /// The desired value. /// </returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="key"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentException"> /// Thrown if <paramref name="key"/> does not match any of the registered configuration keys. /// </exception> public T Value <T>(ConfigurationKeyBase key) { if (key == null) { throw new ArgumentNullException("key"); } foreach (var configuration in _configurations) { if (configuration.HasValueFor(key)) { return(configuration.Value <T>(key)); } } throw new ArgumentException( Resources.Exceptions_Messages_UnknownConfigurationKey, "key"); }
/// <summary> /// Returns the value for the given configuration key. /// </summary> /// <typeparam name="T">The type of the return value.</typeparam> /// <param name="key">The configuration key.</param> /// <returns> /// The desired value. /// </returns> public T Value <T>(ConfigurationKeyBase key) { if (key == null) { throw new ArgumentNullException("key"); } var values = KeyToValueMap(); if (!values.ContainsKey(key)) { throw new ArgumentException( Resources.Exceptions_Messages_UnknownConfigurationKey, "key"); } var obj = values[key]; return((T)obj); }
public bool HasValueFor(ConfigurationKeyBase key) { return((key != null) && KeyToValueMap().ContainsKey(key)); }