Skip to content

Instantly share code, notes, and snippets.

@EdCharbeneau
Created August 10, 2022 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdCharbeneau/430dd7127f2df9a20d7cc28fd33a02a3 to your computer and use it in GitHub Desktop.
Save EdCharbeneau/430dd7127f2df9a20d7cc28fd33a02a3 to your computer and use it in GitHub Desktop.
Adds a JSON configuration source to builder for MAUI using appsettings.json
public static class ConfigurationExtensions
{
/// <summary>
/// Adds a JSON configuration source to builder
/// </summary>
/// <param name="config"></param>
/// <param name="configResourceName"></param>
/// <returns>The IConfigurationBuilder</returns>
public static IConfigurationBuilder AddJsonResource(this IConfigurationBuilder config, string configResourceName)
{
var a = Assembly.GetExecutingAssembly();
using var stream = a.GetManifestResourceStream(configResourceName);
config.AddJsonStream(stream);
return config;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment