// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { var config = new TestConfigParent { Child = new TestConfigChild { Name = "Test" }, Description = "QwertyqWERTY" }; services.AddCustomConfig <TestConfigParent>(config); // services.AddCustomConfig<TestConfigParent>(config); services.Configure <TestConfigParent>(Configuration); services.AddRazorPages(); services.AddServerSideBlazor(); services.AddSingleton <WeatherForecastService>(); // services.AddHostedService<TestService>(); }
public TestService(IOptionsMonitor <TestConfigParent> optionsMonitor, IOptions <TestConfigParent> options) { _options = options.Value; optionsMonitor.OnChange(opt => _options = opt); }