Permalink
Browse files

support config binding json array to IEnumerable collection

  • Loading branch information...
mythz committed Dec 29, 2018
1 parent 53d9079 commit 15e2fcb27c96127d3118e37294795a2d4329d80c
Showing with 14 additions and 0 deletions.
  1. +7 −0 src/ServiceStack/NetCoreAppSettings.cs
  2. +4 −0 tests/CheckWebCore/Startup.cs
  3. +3 −0 tests/CheckWebCore/appsettings.json
@@ -1,6 +1,7 @@
#if NETSTANDARD2_0

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
@@ -21,6 +22,12 @@ private static T Bind<T>(IConfigurationSection config)
{
if (config.Value != null)
return config.Value.ConvertTo<T>();

if (typeof(T).HasInterface(typeof(IEnumerable)))
{
var values = config.GetChildren().Map(x => x.Value);
return values.ConvertTo<T>();
}
}
catch (Exception ex)
{
@@ -63,10 +63,14 @@ public override void Configure(Container container)
DebugMode = AppSettings.Get(nameof(HostConfig.DebugMode), false)
});

var permissions = AppSettings.Get<string[]>("oauth.facebook.Permissions");
var permissionsList = AppSettings.GetList("oauth.facebook.Permissions");

Plugins.Add(new AuthFeature(() => new AuthUserSession(),
new IAuthProvider[] {
new BasicAuthProvider(), //Sign-in with HTTP Basic Auth
new CredentialsAuthProvider(), //HTML Form post of UserName/Password credentials
new FacebookAuthProvider(AppSettings),
}));

Plugins.Add(new RegistrationFeature());
@@ -1,4 +1,7 @@
{
"oauth.facebook.Permissions": [ "email", "user_location" ],
"oauth.facebook.AppId": "868452679921646",
"oauth.facebook.AppSecret": "64487a6bfacaf658c00be77182356503",
"Menu": {
"/": "Home",
"/about": "About",

0 comments on commit 15e2fcb

Please sign in to comment.