本文整理汇总了C#中IConfiguration.GetSubKey方法的典型用法代码示例。如果您正苦于以下问题:C# IConfiguration.GetSubKey方法的具体用法?C# IConfiguration.GetSubKey怎么用?C# IConfiguration.GetSubKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConfiguration
的用法示例。
在下文中一共展示了IConfiguration.GetSubKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigurationLoginProviders
public ConfigurationLoginProviders(IConfiguration config)
{
Facebook = GetProvider(config, nameof(Facebook));
Google = GetProvider(config, nameof(Google));
Microsoft = GetProvider(config, nameof(Microsoft));
Twitter = GetProvider(config, nameof(Twitter));
Azure = new AzureADLoginProviderCredentials(config.GetSubKey(nameof(Azure)));
}
示例2: GetDataFromConfig
private IEnumerable<RouteConfigData> GetDataFromConfig(IConfiguration config)
{
foreach (var template in config.GetSubKey("TemplateCollection").GetSubKeys())
{
yield return
new RouteConfigData()
{
RouteName = template.Key,
RouteTemplateValue = template.Value.Get("TemplateValue")
};
}
}
示例3: ReadProperties
public static void ReadProperties(object obj, IConfiguration config)
{
// No convert on portable or core
#if NET45 || DNX451
if (obj == null || config == null)
{
return;
}
var props = obj.GetType().GetProperties();
foreach (var prop in props)
{
// Only try to set properties with public setters
if (prop.GetSetMethod() == null)
{
continue;
}
var configValue = config.Get(prop.Name);
if (configValue == null)
{
// Try to bind recursively
ReadProperties(prop.GetValue(obj), config.GetSubKey(prop.Name));
continue;
}
var propertyType = prop.PropertyType;
// Handle Nullable<T>
if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
propertyType = Nullable.GetUnderlyingType(propertyType);
}
try
{
prop.SetValue(obj, Convert.ChangeType(configValue, propertyType));
}
catch
{
// Ignore errors
}
}
#endif
}
示例4: ContentDeliveryNetworkConfiguration
public ContentDeliveryNetworkConfiguration(IConfiguration config)
{
Images = config.Get("images");
Scripts = config.GetSubKey("Scripts").ToLookup();
Styles = config.GetSubKey("Styles").ToLookup();
}
示例5: GetProvider
private ILoginProviderCredentials GetProvider(IConfiguration config, string providerName)
{
return new ConfigurationLoginProviderCredentials(config.GetSubKey(providerName));
}