This commit is contained in:
Hao Kung 2017-06-06 12:15:30 -07:00
Родитель 387a77fac3
Коммит 59da969787
1 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -60,10 +60,10 @@ namespace Microsoft.Extensions.Configuration
/// Attempts to bind the given object instance to the configuration section specified by the key by matching property names against configuration keys recursively.
/// </summary>
/// <param name="configuration">The configuration instance to bind.</param>
/// <param name="sectionKey">The key of the configuration section to bind.</param>
/// <param name="key">The key of the configuration section to bind.</param>
/// <param name="instance">The object to bind.</param>
public static void Bind(this IConfiguration configuration, string sectionKey, object instance)
=> configuration.GetSection(sectionKey).Bind(instance);
public static void Bind(this IConfiguration configuration, string key, object instance)
=> configuration.GetSection(key).Bind(instance);
/// <summary>
/// Attempts to bind the given object instance to configuration values by matching property names against configuration keys recursively.
@ -88,11 +88,11 @@ namespace Microsoft.Extensions.Configuration
/// </summary>
/// <typeparam name="T">The type to convert the value to.</typeparam>
/// <param name="configuration">The configuration.</param>
/// <param name="sectionKey">The key of the configuration section's value to convert.</param>
/// <param name="key">The key of the configuration section's value to convert.</param>
/// <returns>The converted value.</returns>
public static T GetValue<T>(this IConfiguration configuration, string sectionKey)
public static T GetValue<T>(this IConfiguration configuration, string key)
{
return GetValue(configuration, sectionKey, default(T));
return GetValue(configuration, key, default(T));
}
/// <summary>
@ -100,12 +100,12 @@ namespace Microsoft.Extensions.Configuration
/// </summary>
/// <typeparam name="T">The type to convert the value to.</typeparam>
/// <param name="configuration">The configuration.</param>
/// <param name="sectionKey">The key of the configuration section's value to convert.</param>
/// <param name="key">The key of the configuration section's value to convert.</param>
/// <param name="defaultValue">The default value to use if no value is found.</param>
/// <returns>The converted value.</returns>
public static T GetValue<T>(this IConfiguration configuration, string sectionKey, T defaultValue)
public static T GetValue<T>(this IConfiguration configuration, string key, T defaultValue)
{
return (T)GetValue(configuration, typeof(T), sectionKey, defaultValue);
return (T)GetValue(configuration, typeof(T), key, defaultValue);
}
/// <summary>
@ -113,11 +113,11 @@ namespace Microsoft.Extensions.Configuration
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <param name="type">The type to convert the value to.</param>
/// <param name="sectionKey">The key of the configuration section's value to convert.</param>
/// <param name="key">The key of the configuration section's value to convert.</param>
/// <returns>The converted value.</returns>
public static object GetValue(this IConfiguration configuration, Type type, string sectionKey)
public static object GetValue(this IConfiguration configuration, Type type, string key)
{
return GetValue(configuration, type, sectionKey, defaultValue: null);
return GetValue(configuration, type, key, defaultValue: null);
}
/// <summary>
@ -125,12 +125,12 @@ namespace Microsoft.Extensions.Configuration
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <param name="type">The type to convert the value to.</param>
/// <param name="sectionKey">The key of the configuration section's value to convert.</param>
/// <param name="key">The key of the configuration section's value to convert.</param>
/// <param name="defaultValue">The default value to use if no value is found.</param>
/// <returns>The converted value.</returns>
public static object GetValue(this IConfiguration configuration, Type type, string sectionKey, object defaultValue)
public static object GetValue(this IConfiguration configuration, Type type, string key, object defaultValue)
{
var value = configuration.GetSection(sectionKey).Value;
var value = configuration.GetSection(key).Value;
if (value != null)
{
return ConvertValue(type, value);