web:asp.net:core:configuration
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
web:asp.net:core:configuration [2017/11/01 18:39] – [Exemple simple] sgariepy | web:asp.net:core:configuration [2023/11/17 20:09] (Version actuelle) – [Providers] sgariepy | ||
---|---|---|---|
Ligne 22: | Ligne 22: | ||
<code csharp> | <code csharp> | ||
{ | { | ||
- | // http:// | ||
" | " | ||
" | " | ||
Ligne 64: | Ligne 63: | ||
this.Configuration.GetSection(" | this.Configuration.GetSection(" | ||
</ | </ | ||
+ | |||
+ | Autre exemple: | ||
+ | |||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | <code csharp> | ||
+ | services.AddOptions(); | ||
+ | |||
+ | services.Configure< | ||
+ | </ | ||
+ | |||
+ | Dans une classe consommatrice, | ||
+ | |||
+ | |||
+ | <code csharp> | ||
+ | public class MyClass | ||
+ | { | ||
+ | private readonly string[] _myOptions; | ||
+ | |||
+ | public MyClass(IOptions< | ||
+ | { | ||
+ | this._options = myOptions.Value.Options; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====== Providers ====== | ||
+ | |||
+ | |||
+ | ^ Provider | ||
+ | | appsettings.json | ||
+ | | appsettings.{ENVIRONMENT}.json | ||
+ | | User Secrets (Developement) | '' | ||
+ | | Environment variables | ||
+ | | Command-line arguments | ||
+ | |||
+ | |||
+ | L' | ||
+ | |||
+ | |||
+ | |||
+ | Source: [[https:// | ||
+ | |||
web/asp.net/core/configuration.1509557998.txt.gz · Dernière modification : 2022/02/02 00:43 (modification externe)