WebC# 如何在.net core 2上的启动中访问IConfigurationRoot?,c#,asp.net-core,asp.net-core-mvc,asp.net-core-2.0,C#,Asp.net Core,Asp.net Core Mvc,Asp.net Core 2.0,我已经用实体框架编写了一个定制的ConfigurationProvider。因为我还想使它在运行时可更新,所以我创建了一个 更新后,我需要刷新配置。 WebDec 26, 2016 · In ASP.NET Core 2.2 and later we can inject IConfiguration anywhere in our application like in your case, you can inject IConfiguration in HomeController and use like this to get the array. string [] array = _config.GetSection ("MyArray").Get (); Share. Improve this answer. Follow.
c# - Using IOptions and load options from database with multi …
http://duoduokou.com/csharp/40870290995600702959.html WebApr 2, 2024 · Here is the code to create a typed ConfigurationRoot: /// /// The configuration for this application. /// public class ApplicationConfiguration : ConfigurationRoot { /// dragon city birmingham
c# - How to Inject
WebJul 11, 2024 · IConfigurationSection myListConfigSection = configurationRoot.GetSection ("ListA"); List paramList; //Get does not exist //paramList = myListConfigSection.Get (); string paramListJson = myListConfigSection.Value // is null // won't work neither because paramListJson is null paramList = JsonConvert.DeserializeObject (paramListJson); … WebNov 3, 2024 · Using this answer to mock the IConfiguration methods from an ASP.NET Core app. I need to mock an IConfigurationSection to return a string array. My configuration class looks like this: public class LoggingConfiguration { public string ApplicationName { get; set; } public string [] Loggers { get; set; } } appsettings.json Web1) Install Nerdle.AutoConfig from NuGet. 2) Define your ServiceConfig type (either a concrete class or just an interface, either will do) public interface IServiceConfiguration { int Port { get; } ReportType ReportType { get; } } 3) You'll need a type to hold the collection, e.g. emily\u0027s nursery sunderland