Skip to content

Initialize CustomSettings with values from appsettings.json #14996

Answered by weirdyang
weirdyang asked this question in Q&A
Discussion options

You must be logged in to vote

Ok this is the full code to acheive what I want:

  1. to initialize site settings from appsettings if it available,
  2. be able to display the settings
  3. allow it to be configured if the appsettings section is missing.

Hopefully someone else finds it useful

    [Feature("CustomSettings.TestSettings")]
    public class Startup : StartupBase
    {
        public IConfiguration Configuration { get; }

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public override async void ConfigureServices(IServiceCollection services)
        {
            services.AddScoped<IDisplayDriver<ISite>, TestSettingsDisplayDriver>();
           …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by weirdyang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant