You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1023 B
26 lines
1023 B
using Microsoft.Extensions.Configuration;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Infrastructure.Extensions
|
|
{
|
|
public static class ConfigurationExtensions
|
|
{
|
|
public static Dictionary<string, string> GetConnectionStringValues(this IConfiguration configuration, string name)
|
|
{
|
|
return configuration.GetConnectionString(name).Split(';')
|
|
.ToDictionary(o => o.Split('=')[0], o => o.Split('=')[1]);
|
|
}
|
|
|
|
public static string GetAppSetting(this IConfiguration configuration, string name, string defaultValue = null)
|
|
{
|
|
return configuration.GetSection("AppSettings").GetValue<string>(name, defaultValue);
|
|
}
|
|
|
|
public static Dictionary<string, string> GetAppSettings(this IConfiguration configuration, string name, string defaultValue = null)
|
|
{
|
|
return configuration.GetAppSetting(name).Split(';')
|
|
.ToDictionary(o => o.Split('=')[0], o => o.Split('=')[1]);
|
|
}
|
|
}
|
|
} |