@@ -5,7 +5,7 @@ description: Discover how to use the options pattern to represent groups of rela
55monikerRange : ' >= aspnetcore-2.1'
66ms.author : riande
77ms.custom : mvc
8- ms.date : 11/18 /2019
8+ ms.date : 01/07 /2019
99uid : fundamentals/configuration/options
1010---
1111# Options pattern in ASP.NET Core
@@ -48,7 +48,7 @@ The [Microsoft.Extensions.Options.ConfigurationExtensions](https://www.nuget.org
4848
4949## General options configuration
5050
51- General options configuration is demonstrated as Example & num ; 1 in the sample app.
51+ General options configuration is demonstrated as Example 1 in the sample app.
5252
5353An options class must be non-abstract with a public parameterless constructor. The following class, ` MyOptions ` , has two properties, ` Option1 ` and ` Option2 ` . Setting default values is optional, but the class constructor in the following example sets the default value of ` Option1 ` . ` Option2 ` has a default value set by initializing the property directly (* Models/MyOptions.cs* ):
5454
@@ -92,7 +92,7 @@ option1 = value1_from_json, option2 = -1
9292
9393## Configure simple options with a delegate
9494
95- Configuring simple options with a delegate is demonstrated as Example # 2 in the sample app .
95+ Configuring simple options with a delegate is demonstrated as Example 2 in the sample app.
9696
9797Use a delegate to set options values. The sample app uses the `MyOptionsWithDelegateConfig` class (*Models/MyOptionsWithDelegateConfig.cs*):
9898
@@ -122,7 +122,7 @@ delegate_option1 = value1_configured_by_delegate, delegate_option2 = 500
122122
123123## Suboptions configuration
124124
125- Suboptions configuration is demonstrated as Example & num ; 3 in the sample app .
125+ Suboptions configuration is demonstrated as Example 3 in the sample app .
126126
127127Apps should create options classes that pertain to specific scenario groups (classes ) in the app . Parts of the app that require configuration values should only have access to the configuration values that they use .
128128
@@ -158,7 +158,7 @@ subOption1 = subvalue1_from_json, subOption2 = 200
158158
159159## Options injection
160160
161- Options injection is demonstrated as Example & num ; 4 in the sample app .
161+ Options injection is demonstrated as Example 4 in the sample app .
162162
163163Inject <xref :Microsoft .Extensions .Options .IOptionsMonitor %601> into :
164164
@@ -183,7 +183,7 @@ When the app is run, the options values are shown in the rendered page:
183183
184184## Reload configuration data with IOptionsSnapshot
185185
186- Reloading configuration data with < xref : Microsoft .Extensions .Options .IOptionsSnapshot % 601 > is demonstrated in Example & num ; 5 in the sample app .
186+ Reloading configuration data with <xref :Microsoft .Extensions .Options .IOptionsSnapshot %601> is demonstrated in Example 5 in the sample app .
187187
188188Using <xref :Microsoft .Extensions .Options .IOptionsSnapshot %601>, options are computed once per request when accessed and cached for the lifetime of the request .
189189
@@ -214,9 +214,9 @@ snapshot option1 = value1_from_json UPDATED, snapshot option2 = 200
214214
215215## Named options support with IConfigureNamedOptions
216216
217- Named options support with < xref : Microsoft .Extensions .Options .IConfigureNamedOptions % 601 > is demonstrated as Example & num ; 6 in the sample app .
217+ Named options support with <xref :Microsoft .Extensions .Options .IConfigureNamedOptions %601> is demonstrated as Example 6 in the sample app .
218218
219- * Named options * support allows the app to distinguish between named options configurations . In the sample app , named options are declared with [OptionsServiceCollectionExtensions .Configure ](xref :Microsoft .Extensions .DependencyInjection .OptionsServiceCollectionExtensions .Configure * ), which calls the [ConfigureNamedOptions \< TOptions > .Configure ](xref :Microsoft .Extensions .Options .ConfigureNamedOptions `1 .Configure * ) extension method :
219+ Named options support allows the app to distinguish between named options configurations . In the sample app , named options are declared with [OptionsServiceCollectionExtensions.Configure](xref :Microsoft .Extensions .DependencyInjection .OptionsServiceCollectionExtensions .Configure *), which calls the [ConfigureNamedOptions\<TOptions>.Configure](xref :Microsoft .Extensions .Options .ConfigureNamedOptions `1.Configure *) extension method . Named options are case sensitive .
220220
221221[!code-csharp[](options /samples /3.x /OptionsSample /Startup .cs ?name =snippet_Example6 )]
222222
@@ -472,7 +472,7 @@ Reference the [Microsoft.AspNetCore.App metapackage](xref:fundamentals/metapacka
472472
473473## General options configuration
474474
475- General options configuration is demonstrated as Example & num ; 1 in the sample app.
475+ General options configuration is demonstrated as Example 1 in the sample app.
476476
477477An options class must be non-abstract with a public parameterless constructor. The following class, ` MyOptions ` , has two properties, ` Option1 ` and ` Option2 ` . Setting default values is optional, but the class constructor in the following example sets the default value of ` Option1 ` . ` Option2 ` has a default value set by initializing the property directly (* Models/MyOptions.cs* ):
478478
@@ -516,7 +516,7 @@ option1 = value1_from_json, option2 = -1
516516
517517## Configure simple options with a delegate
518518
519- Configuring simple options with a delegate is demonstrated as Example # 2 in the sample app .
519+ Configuring simple options with a delegate is demonstrated as Example 2 in the sample app.
520520
521521Use a delegate to set options values. The sample app uses the `MyOptionsWithDelegateConfig` class (*Models/MyOptionsWithDelegateConfig.cs*):
522522
@@ -546,7 +546,7 @@ delegate_option1 = value1_configured_by_delegate, delegate_option2 = 500
546546
547547## Suboptions configuration
548548
549- Suboptions configuration is demonstrated as Example & num ; 3 in the sample app .
549+ Suboptions configuration is demonstrated as Example 3 in the sample app .
550550
551551Apps should create options classes that pertain to specific scenario groups (classes ) in the app . Parts of the app that require configuration values should only have access to the configuration values that they use .
552552
@@ -582,7 +582,7 @@ subOption1 = subvalue1_from_json, subOption2 = 200
582582
583583## Options injection
584584
585- Options injection is demonstrated as Example & num ; 4 in the sample app .
585+ Options injection is demonstrated as Example 4 in the sample app .
586586
587587Inject <xref :Microsoft .Extensions .Options .IOptionsMonitor %601> into :
588588
@@ -607,7 +607,7 @@ When the app is run, the options values are shown in the rendered page:
607607
608608## Reload configuration data with IOptionsSnapshot
609609
610- Reloading configuration data with < xref : Microsoft .Extensions .Options .IOptionsSnapshot % 601 > is demonstrated in Example & num ; 5 in the sample app .
610+ Reloading configuration data with <xref :Microsoft .Extensions .Options .IOptionsSnapshot %601> is demonstrated in Example 5 in the sample app .
611611
612612Using <xref :Microsoft .Extensions .Options .IOptionsSnapshot %601>, options are computed once per request when accessed and cached for the lifetime of the request .
613613
@@ -638,9 +638,9 @@ snapshot option1 = value1_from_json UPDATED, snapshot option2 = 200
638638
639639## Named options support with IConfigureNamedOptions
640640
641- Named options support with < xref : Microsoft .Extensions .Options .IConfigureNamedOptions % 601 > is demonstrated as Example & num ; 6 in the sample app .
641+ Named options support with <xref :Microsoft .Extensions .Options .IConfigureNamedOptions %601> is demonstrated as Example 6 in the sample app .
642642
643- * Named options * support allows the app to distinguish between named options configurations . In the sample app , named options are declared with [OptionsServiceCollectionExtensions .Configure ](xref :Microsoft .Extensions .DependencyInjection .OptionsServiceCollectionExtensions .Configure * ), which calls the [ConfigureNamedOptions \< TOptions > .Configure ](xref :Microsoft .Extensions .Options .ConfigureNamedOptions `1 .Configure * ) extension method :
643+ Named options support allows the app to distinguish between named options configurations . In the sample app , named options are declared with [OptionsServiceCollectionExtensions.Configure](xref :Microsoft .Extensions .DependencyInjection .OptionsServiceCollectionExtensions .Configure *), which calls the [ConfigureNamedOptions\<TOptions>.Configure](xref :Microsoft .Extensions .Options .ConfigureNamedOptions `1.Configure *) extension method . Named options are case sensitive .
644644
645645[!code-csharp[](options /samples /2.x /OptionsSample /Startup .cs ?name =snippet_Example6 )]
646646
@@ -894,7 +894,7 @@ Reference the [Microsoft.AspNetCore.App metapackage](xref:fundamentals/metapacka
894894
895895## General options configuration
896896
897- General options configuration is demonstrated as Example & num ; 1 in the sample app.
897+ General options configuration is demonstrated as Example 1 in the sample app.
898898
899899An options class must be non-abstract with a public parameterless constructor. The following class, ` MyOptions ` , has two properties, ` Option1 ` and ` Option2 ` . Setting default values is optional, but the class constructor in the following example sets the default value of ` Option1 ` . ` Option2 ` has a default value set by initializing the property directly (* Models/MyOptions.cs* ):
900900
@@ -938,7 +938,7 @@ option1 = value1_from_json, option2 = -1
938938
939939## Configure simple options with a delegate
940940
941- Configuring simple options with a delegate is demonstrated as Example # 2 in the sample app .
941+ Configuring simple options with a delegate is demonstrated as Example 2 in the sample app.
942942
943943Use a delegate to set options values. The sample app uses the `MyOptionsWithDelegateConfig` class (*Models/MyOptionsWithDelegateConfig.cs*):
944944
@@ -968,7 +968,7 @@ delegate_option1 = value1_configured_by_delegate, delegate_option2 = 500
968968
969969## Suboptions configuration
970970
971- Suboptions configuration is demonstrated as Example & num ; 3 in the sample app .
971+ Suboptions configuration is demonstrated as Example 3 in the sample app .
972972
973973Apps should create options classes that pertain to specific scenario groups (classes ) in the app . Parts of the app that require configuration values should only have access to the configuration values that they use .
974974
@@ -1004,7 +1004,7 @@ subOption1 = subvalue1_from_json, subOption2 = 200
10041004
10051005## Options provided by a view model or with direct view injection
10061006
1007- Options provided by a view model or with direct view injection is demonstrated as Example & num ; 4 in the sample app .
1007+ Options provided by a view model or with direct view injection is demonstrated as Example 4 in the sample app .
10081008
10091009Options can be supplied in a view model or by injecting <xref :Microsoft .Extensions .Options .IOptionsMonitor %601> directly into a view (*Pages /Index .cshtml .cs *):
10101010
@@ -1024,7 +1024,7 @@ When the app is run, the options values are shown in the rendered page:
10241024
10251025## Reload configuration data with IOptionsSnapshot
10261026
1027- Reloading configuration data with < xref : Microsoft .Extensions .Options .IOptionsSnapshot % 601 > is demonstrated in Example & num ; 5 in the sample app .
1027+ Reloading configuration data with <xref :Microsoft .Extensions .Options .IOptionsSnapshot %601> is demonstrated in Example 5 in the sample app .
10281028
10291029<xref :Microsoft .Extensions .Options .IOptionsSnapshot %601> supports reloading options with minimal processing overhead .
10301030
@@ -1052,9 +1052,9 @@ snapshot option1 = value1_from_json UPDATED, snapshot option2 = 200
10521052
10531053## Named options support with IConfigureNamedOptions
10541054
1055- Named options support with < xref : Microsoft .Extensions .Options .IConfigureNamedOptions % 601 > is demonstrated as Example & num ; 6 in the sample app .
1055+ Named options support with <xref :Microsoft .Extensions .Options .IConfigureNamedOptions %601> is demonstrated as Example 6 in the sample app .
10561056
1057- * Named options * support allows the app to distinguish between named options configurations . In the sample app , named options are declared with [OptionsServiceCollectionExtensions .Configure ](xref :Microsoft .Extensions .DependencyInjection .OptionsServiceCollectionExtensions .Configure * ), which calls the [ConfigureNamedOptions \< TOptions > .Configure ](xref :Microsoft .Extensions .Options .ConfigureNamedOptions `1 .Configure * ) extension method :
1057+ Named options support allows the app to distinguish between named options configurations . In the sample app , named options are declared with [OptionsServiceCollectionExtensions.Configure](xref :Microsoft .Extensions .DependencyInjection .OptionsServiceCollectionExtensions .Configure *), which calls the [ConfigureNamedOptions\<TOptions>.Configure](xref :Microsoft .Extensions .Options .ConfigureNamedOptions `1.Configure *) extension method . Named options are case sensitive .
10581058
10591059[!code-csharp[](options /samples /2.x /OptionsSample /Startup .cs ?name =snippet_Example6 )]
10601060
0 commit comments