你们可以将它添加到ServiceStack中吗?我们大多将设置保存在单独的文件中;
<configSections>
<section name="FluentFilter.AuthenticationActionFilterAttribute" type="System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" allowExeDefinition="MachineToLocalUser" />
</configSections>
<FluentFilter.AuthenticationActionFilterAttribute file="FluentFilter.AuthenticationActionFilterAttribute.config" />
这是我的配置文件:
<FluentFilter.AuthenticationActionFilterAttribute>
<add key="RouteValueDictionary" value='{area:"Identity",controller:"auth",action:"logon",ServiceStackAuth:"/api/auth/googleopenid?Continue={0}"}' />
<add key="Area" value='["Support","Sports"]' />
<add key="FilterType" value="Pingo.Contrib.ServiceStack.Filters.AuthenticationActionFilterAttribute"/>
</FluentFilter.AuthenticationActionFilterAttribute>
最后,基于您的 AppSettings 类的 AppSettingsSectionSettings。
/// <summary>
/// More familiar name for the new crowd.
/// </summary>
public class AppSettingsSectionSettings : AppSettingsBase
{
private System.Configuration.Configuration _configuration;
private class ConfigurationManagerWrapper : ISettings
{
private readonly AppSettingsSection _appSettingsSection;
public ConfigurationManagerWrapper(AppSettingsSection appSettingsSection)
{
_appSettingsSection = appSettingsSection;
}
public string Get(string key)
{
return _appSettingsSection.Settings[key].Value;
}
}
public AppSettingsSectionSettings(AppSettingsSection appSettingsSection)
: base(new ConfigurationManagerWrapper(appSettingsSection))
{
}
/// <summary>
/// Returns string if exists, otherwise null
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public override string GetString(string name) //Keeping backwards compatible
{
return base.GetNullableString(name);
}
}