0

你们可以将它添加到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);
    }
}
4

1 回答 1

1

您可以提交一个拉取请求,但这似乎是一个足够简单的自定义,它应该与您自己的代码一起使用。如果其他人处于相同的情况,他们将能够在 StackOverflow 上搜索并找到它。

于 2013-11-04T15:34:52.593 回答