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: README.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,6 +120,40 @@ is enabled - __but__ it can only draw on values that were hard-coded, or inserte
120
120
Although most initialization parameters can take advantage of this flexibility, it might not always make sense to apply this technique to all parameters. Of the
121
121
base parameters defined for all key/value config builders, `mode` and `tokenPrefix` stand out as the two that *do not allow* reading from `appSettings`.
122
122
123
+
## Strict vs Greedy vs Expand
124
+
Be aware that ConfigurationBuilders in the framework are a two-phase extension point. The first phase gets called when the config system reads the raw xml of
125
+
a config section in an individual file. This phase works directly on the raw string xml contents of the config section as it exists in the config
126
+
file containting the `configBuilders` tag for the section. Meaning if you tagged 'appSettings' with your config builder in you app.exe.config, then phase one
127
+
only sees the settings you have in app.exe.config. Nothing from machine.config or any other config file in the processing hierarchy is visible.
128
+
129
+
The second phase gets called after the config system has taken that raw xml input and turned it into a `ConfigurationSection` object - complete with inherited
130
+
values from config files higher up the chain. Using the 'appSettings' in app.exe.config example again, this means that when a config builder is tagged in
131
+
app.exe.config, it will operate on a `ConfigurationSection` object that contains settings contained in app.exe.config _in addition to_ the settings that were
132
+
defined in higher config levels like machine.config.
133
+
134
+
If your key/value config builder is set in `Strict` or `Greedy` mode, then it will operate in phase 2.
135
+
136
+
If your key/value config builder is set in `Expand` mode, then it will operate in phase 1 on the raw xml __string__. So, if you had a custom section like this:
137
+
```xml
138
+
<MyCustomSectionconfigBuilders="environment">
139
+
<addkey="custom_key"value="${custom_value}" />
140
+
${full_add_remove_element}
141
+
</MyCustomSection>
142
+
```
143
+
144
+
The `environment` config builder would look for environment variables named 'custom_value' and 'full_add_remove_element' and directly replace the tokens in that xml string with the environment variable values. (Or leave the token as is if there is no matching environment variable.) Assuming your environment has
then the resulting xml that gets used to build the config object would look like this:
150
+
```xml
151
+
<MyCustomSectionconfigBuilders="environment">
152
+
<addkey="custom_key"value="42" />
153
+
<removekey="custom_key"/>
154
+
</MyCustomSection>
155
+
```
156
+
123
157
## Config Builders In This Project
124
158
*Note about following codeboxes: Parameters inside `[]`s are optional. Parameters grouped in `()`s are mutually exclusive. Parameters beginning with `@` allow appSettings substitution. The first line of parameters are common to all builders and optional. Their meaning and use are [documented above](#keyvalue-config-builders) and they are grouped on one line for brevity. Because different builders have a different default value for `optional`, this default is also specified in this first line summary of common attributes.*
0 commit comments