-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from RocketSurgeonsGuild/feature/configuration…
…-enhancements Feature/configuration enhancements
- Loading branch information
Showing
21 changed files
with
351 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.Extensions.FileProviders; | ||
using IMsftConfigurationBuilder = Microsoft.Extensions.Configuration.IConfigurationBuilder; | ||
|
||
namespace Rocket.Surgery.Extensions.Configuration | ||
{ | ||
/// <summary> | ||
/// Options for configuring a hosting environment | ||
/// </summary> | ||
public class ConfigurationOptions | ||
{ | ||
/// <summary> | ||
/// Additional settings providers to be inserted after the default application settings file (typically appsettings.json) | ||
/// </summary> | ||
public List<Func<IMsftConfigurationBuilder, IMsftConfigurationBuilder>> ApplicationConfiguration { get; } = new List<Func<IMsftConfigurationBuilder, IMsftConfigurationBuilder>>(); | ||
|
||
/// <summary> | ||
/// Additional settings providers to be inserted after the default environment application settings file (typically appsettings.{env}.json) | ||
/// </summary> | ||
public List<Func<IMsftConfigurationBuilder, string, IMsftConfigurationBuilder>> EnvironmentConfiguration { get; } = new List<Func<IMsftConfigurationBuilder, string, IMsftConfigurationBuilder>>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Configuration.Abstractions/ProxyConfigurationBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.Extensions.Configuration; | ||
using IMsftConfigurationBuilder = Microsoft.Extensions.Configuration.IConfigurationBuilder; | ||
|
||
namespace Rocket.Surgery.Extensions.Configuration | ||
{ | ||
class ProxyConfigurationBuilder : IMsftConfigurationBuilder | ||
{ | ||
private readonly IMsftConfigurationBuilder _builder; | ||
private readonly IList<IConfigurationSource> _sources = new List<IConfigurationSource>(); | ||
|
||
public ProxyConfigurationBuilder(IMsftConfigurationBuilder builder) | ||
{ | ||
this._builder = builder; | ||
} | ||
|
||
public IDictionary<string, object> Properties => _builder.Properties; | ||
|
||
public IList<IConfigurationSource> Sources => _builder.Sources; | ||
|
||
public IMsftConfigurationBuilder Add(IConfigurationSource source) | ||
{ | ||
_sources.Add(source); | ||
return this; | ||
} | ||
|
||
public IEnumerable<IConfigurationSource> GetAdditionalSources() | ||
{ | ||
return _sources; | ||
} | ||
|
||
public IConfigurationRoot Build() | ||
{ | ||
return _builder.Build(); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Configuration.Abstractions/ProxyConfigurationBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using IMsftConfigurationBuilder = Microsoft.Extensions.Configuration.IConfigurationBuilder; | ||
|
||
namespace Rocket.Surgery.Extensions.Configuration | ||
{ | ||
static class ProxyConfigurationBuilderExtensions | ||
{ | ||
public static T Apply<T>(this T builder, IEnumerable<Func<IMsftConfigurationBuilder, IMsftConfigurationBuilder>> builders) where T : IMsftConfigurationBuilder | ||
{ | ||
foreach (var b in builders) | ||
{ | ||
b(builder); | ||
} | ||
return builder; | ||
} | ||
|
||
public static T Apply<T>(this T builder, IEnumerable<Func<IMsftConfigurationBuilder, string, IMsftConfigurationBuilder>> builders, string environmentName) where T : IMsftConfigurationBuilder | ||
{ | ||
foreach (var b in builders) | ||
{ | ||
b(builder, environmentName); | ||
} | ||
return builder; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.