You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/configuration/options.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,19 +108,19 @@ In the preceding code, by default, changes to the JSON configuration file after
108
108
109
109
<a name="named"></a>
110
110
111
-
## Specify a custom key name for a configuration property using ConfigurationKeyName
111
+
## Specify a custom key name for a configuration property using `ConfigurationKeyName`
112
112
113
-
By default, the property names of the Options class are used as the key name in the configuration source. For example, if the property name is `Title`, the key name in the configuration is `Title` as well.
113
+
By default, the property names of the options class are used as the key name in the configuration source. If the property name is `Title`, the key name in the configuration is `Title` as well.
114
114
115
-
When the names differentiate, you can use [`ConfigurationKeyName` attribute](xref:Microsoft.Extensions.Configuration.ConfigurationKeyNameAttribute) to specify the key name in the configuration source. Using this technique, you can map a property in the configuration to one in your code with a different name.
115
+
When the names differentiate, you can use the [`ConfigurationKeyName` attribute](xref:Microsoft.Extensions.Configuration.ConfigurationKeyNameAttribute) to specify the key name in the configuration source. Using this technique, you can map a property in the configuration to one in your code with a different name.
116
116
117
-
This is useful when the property name in the configuration source is not a valid C# identifier, or when you want to use a different name in your code.
117
+
This is useful when the property name in the configuration source is not a valid C# identifier or when you want to use a different name in your code.
118
118
119
-
For example, consider the following Options class:
119
+
For example, consider the following options class:
With the following `appsettings.json`, the `Title` and `Name` class properties are bound to the `position-title` and `position-name` from the `appsettings.json` file:
123
+
The `Title` and `Name` class properties are bound to the `position-title` and `position-name` from the following `appsettings.json` file:
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/configuration/options/samples/6.x/OptionsSample/Models/PositionOptionsWithConfigurationKeyName.cs
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,10 @@ public class PositionOptionsWithConfigurationKeyName
0 commit comments