-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
AppSettingsExpressionBuilder.xml
313 lines (281 loc) · 22.8 KB
/
AppSettingsExpressionBuilder.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<Type Name="AppSettingsExpressionBuilder" FullName="System.Web.Compilation.AppSettingsExpressionBuilder">
<TypeSignature Language="C#" Value="public class AppSettingsExpressionBuilder : System.Web.Compilation.ExpressionBuilder" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit AppSettingsExpressionBuilder extends System.Web.Compilation.ExpressionBuilder" />
<TypeSignature Language="DocId" Value="T:System.Web.Compilation.AppSettingsExpressionBuilder" />
<TypeSignature Language="VB.NET" Value="Public Class AppSettingsExpressionBuilder
Inherits ExpressionBuilder" />
<TypeSignature Language="F#" Value="type AppSettingsExpressionBuilder = class
 inherit ExpressionBuilder" />
<TypeSignature Language="C++ CLI" Value="public ref class AppSettingsExpressionBuilder : System::Web::Compilation::ExpressionBuilder" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Web.Compilation.ExpressionBuilder</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5">
<AttributeName Language="C#">[System.Web.Compilation.ExpressionEditor("System.Web.UI.Design.AppSettingsExpressionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]</AttributeName>
<AttributeName Language="F#">[<System.Web.Compilation.ExpressionEditor("System.Web.UI.Design.AppSettingsExpressionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Web.Compilation.ExpressionPrefix("AppSettings")]</AttributeName>
<AttributeName Language="F#">[<System.Web.Compilation.ExpressionPrefix("AppSettings")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Web.Compilation.ExpressionEditor("System.Web.UI.Design.AppSettingsExpressionEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]</AttributeName>
<AttributeName Language="F#">[<System.Web.Compilation.ExpressionEditor("System.Web.UI.Design.AppSettingsExpressionEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Retrieves values, as specified in a declarative expression, from the <see langword="<appSettings>" /> section of the Web.config file.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.Compilation.AppSettingsExpressionBuilder> class provides access to values in the `<appSettings>` section of the Web.config file. The `<appSettings>` section of the Web.config file contains application-specific values in key/value pairs.
An application value is retrieved by assigning an expression of the form
`<%$ AppSettings: appSettingsKey %>`
to a property in a control declaration. The part of the expression before the colon (:) designates the type of expression to be retrieved, and the part after the colon signifies the key. The preceding expression would retrieve the following value from the Web.config file.
`<appSettings>`
`<add key="appSettingsKey" value="appSettingsValue"/>`
`</appSettings>`
When the page parser encounters an expression with the `AppSettings` prefix, it creates an instance of the <xref:System.Web.Compilation.AppSettingsExpressionBuilder> class to handle the expression.
If the expression is encountered in a page that will be compiled, the <xref:System.Web.Compilation.AppSettingsExpressionBuilder> object generates code to retrieve the specified value from the Web.config file. This code is executed during the execution of the generated page class. If the expression is encountered in a page that will not be compiled, the <xref:System.Web.Compilation.AppSettingsExpressionBuilder> object returns the value from the Web.config file when the page is parsed and executed.
## Examples
The following code example demonstrates how to retrieve an application settings value in a page that is not compiled.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Compilation.AppSettingsExpressionBuilder/CS/Default.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Compilation.AppSettingsExpressionBuilder/VB/Default.aspx" id="Snippet1":::
This code retrieves the following expression from the Web.config file.
`<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">`
`<appSettings>`
`<add key="thisSeason" value="Fall"/>`
`</appSettings>`
`</configuration>`
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.Design.AppSettingsExpressionEditor" />
<altmember cref="T:System.Configuration.ConfigurationManager" />
<altmember cref="P:System.Configuration.ConfigurationManager.AppSettings" />
<altmember cref="T:System.Web.UI.CompilationMode" />
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/d5bd1tad(v=vs.100)">ASP.NET Expressions Overview</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public AppSettingsExpressionBuilder ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Compilation.AppSettingsExpressionBuilder.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 AppSettingsExpressionBuilder();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.Compilation.AppSettingsExpressionBuilder" /> class.</summary>
<remarks>To be added.</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/d5bd1tad(v=vs.100)">ASP.NET Expressions Overview</related>
</Docs>
</Member>
<Member MemberName="EvaluateExpression">
<MemberSignature Language="C#" Value="public override object EvaluateExpression (object target, System.Web.UI.BoundPropertyEntry entry, object parsedData, System.Web.Compilation.ExpressionBuilderContext context);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance object EvaluateExpression(object target, class System.Web.UI.BoundPropertyEntry entry, object parsedData, class System.Web.Compilation.ExpressionBuilderContext context) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Compilation.AppSettingsExpressionBuilder.EvaluateExpression(System.Object,System.Web.UI.BoundPropertyEntry,System.Object,System.Web.Compilation.ExpressionBuilderContext)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function EvaluateExpression (target As Object, entry As BoundPropertyEntry, parsedData As Object, context As ExpressionBuilderContext) As Object" />
<MemberSignature Language="F#" Value="override this.EvaluateExpression : obj * System.Web.UI.BoundPropertyEntry * obj * System.Web.Compilation.ExpressionBuilderContext -> obj" Usage="appSettingsExpressionBuilder.EvaluateExpression (target, entry, parsedData, context)" />
<MemberSignature Language="C++ CLI" Value="public:
 override System::Object ^ EvaluateExpression(System::Object ^ target, System::Web::UI::BoundPropertyEntry ^ entry, System::Object ^ parsedData, System::Web::Compilation::ExpressionBuilderContext ^ context);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="target" Type="System.Object" />
<Parameter Name="entry" Type="System.Web.UI.BoundPropertyEntry" />
<Parameter Name="parsedData" Type="System.Object" />
<Parameter Name="context" Type="System.Web.Compilation.ExpressionBuilderContext" />
</Parameters>
<Docs>
<param name="target">The object that contains the property entry.</param>
<param name="entry">The property to which the expression is bound.</param>
<param name="parsedData">The object that represents parsed data as returned by <see cref="M:System.Web.Compilation.ExpressionBuilder.ParseExpression(System.String,System.Type,System.Web.Compilation.ExpressionBuilderContext)" />.</param>
<param name="context">Properties for the control or page.</param>
<summary>Returns a value from the <see langword="<appSettings>" /> section of the Web.config file.</summary>
<returns>The <see cref="T:System.Object" /> associated with a key in the <see langword="<appSettings>" /> section of the Web.config file.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method is called when an expression of the form `<%$ AppSettings: someApplicationSetting %>` is encountered in a no-compile page. It retrieves the appropriate value from the key/value pairs in the `<appSettings>` section of the Web.config file. This method overrides <xref:System.Web.Compilation.ExpressionBuilder.EvaluateExpression%2A> by calling the <xref:System.Web.Compilation.AppSettingsExpressionBuilder.GetAppSetting%2A> method with the <xref:System.Web.UI.BoundPropertyEntry.Expression%2A> property as the `key` parameter, the <xref:System.Web.UI.PropertyEntry.Name%2A> property on the <xref:System.Web.UI.PropertyEntry.PropertyInfo%2A?displayProperty=nameWithType> property as the `propertyName` parameter, and the <xref:System.Type> of the `target` parameter as the `targetType` parameter.
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.CompilationMode" />
<altmember cref="P:System.Configuration.ConfigurationManager.AppSettings" />
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/d5bd1tad(v=vs.100)">ASP.NET Expressions Overview</related>
</Docs>
</Member>
<MemberGroup MemberName="GetAppSetting">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Returns a value from the <see langword="&lt;appSettings&gt;" /> section of the Web.config file.</summary>
</Docs>
</MemberGroup>
<Member MemberName="GetAppSetting">
<MemberSignature Language="C#" Value="public static object GetAppSetting (string key);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig object GetAppSetting(string key) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Compilation.AppSettingsExpressionBuilder.GetAppSetting(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetAppSetting (key As String) As Object" />
<MemberSignature Language="F#" Value="static member GetAppSetting : string -> obj" Usage="System.Web.Compilation.AppSettingsExpressionBuilder.GetAppSetting key" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Object ^ GetAppSetting(System::String ^ key);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="key" Type="System.String" />
</Parameters>
<Docs>
<param name="key">The key for the value to be retrieved from the configuration file.</param>
<summary>Returns a value from the <see langword="<appSettings>" /> section of the Web.config file.</summary>
<returns>The <see cref="T:System.Object" /> associated with the key in the <see langword="<appSettings>" /> section of the Web.config file.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method retrieves the appropriate value from the key/value pairs in the `<appSettings>` section of the Web.config file. It retrieves the value by getting the <xref:System.Configuration.ConfigurationManager.AppSettings%2A> property with the key as the index. The <xref:System.Object> returned is of the type <xref:System.String>.
]]></format>
</remarks>
<exception cref="T:System.InvalidOperationException">The key is not found in Web.config.</exception>
<altmember cref="P:System.Configuration.ConfigurationManager.AppSettings" />
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/d5bd1tad(v=vs.100)">ASP.NET Expressions Overview</related>
</Docs>
</Member>
<Member MemberName="GetAppSetting">
<MemberSignature Language="C#" Value="public static object GetAppSetting (string key, Type targetType, string propertyName);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig object GetAppSetting(string key, class System.Type targetType, string propertyName) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Compilation.AppSettingsExpressionBuilder.GetAppSetting(System.String,System.Type,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetAppSetting (key As String, targetType As Type, propertyName As String) As Object" />
<MemberSignature Language="F#" Value="static member GetAppSetting : string * Type * string -> obj" Usage="System.Web.Compilation.AppSettingsExpressionBuilder.GetAppSetting (key, targetType, propertyName)" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Object ^ GetAppSetting(System::String ^ key, Type ^ targetType, System::String ^ propertyName);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="key" Type="System.String" />
<Parameter Name="targetType" Type="System.Type" />
<Parameter Name="propertyName" Type="System.String" />
</Parameters>
<Docs>
<param name="key">The key for a value to be retrieved from the configuration file.</param>
<param name="targetType">The type of the object that contains the property entry.</param>
<param name="propertyName">The name of the property to which the expression is bound.</param>
<summary>Returns a value from the <see langword="<appSettings>" /> section of the Web.config file with the value converted to a target type.</summary>
<returns>The <see cref="T:System.Object" /> associated with the key in the <see langword="<appSettings>" /> section of the Web.config file.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method retrieves the appropriate value from the key/value pairs in the `<appSettings>` section of the Web.config file. The value is retrieved by getting the <xref:System.Configuration.ConfigurationManager.AppSettings%2A> property with the key as the index. The resulting string value is converted to a new type based on the `targetType` and `propertyName` parameters.
]]></format>
</remarks>
<exception cref="T:System.InvalidOperationException">The key is not found in Web.config.
-or-
The return value could not be converted.</exception>
<altmember cref="P:System.Configuration.ConfigurationManager.AppSettings" />
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/d5bd1tad(v=vs.100)">ASP.NET Expressions Overview</related>
</Docs>
</Member>
<Member MemberName="GetCodeExpression">
<MemberSignature Language="C#" Value="public override System.CodeDom.CodeExpression GetCodeExpression (System.Web.UI.BoundPropertyEntry entry, object parsedData, System.Web.Compilation.ExpressionBuilderContext context);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance class System.CodeDom.CodeExpression GetCodeExpression(class System.Web.UI.BoundPropertyEntry entry, object parsedData, class System.Web.Compilation.ExpressionBuilderContext context) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Compilation.AppSettingsExpressionBuilder.GetCodeExpression(System.Web.UI.BoundPropertyEntry,System.Object,System.Web.Compilation.ExpressionBuilderContext)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetCodeExpression (entry As BoundPropertyEntry, parsedData As Object, context As ExpressionBuilderContext) As CodeExpression" />
<MemberSignature Language="F#" Value="override this.GetCodeExpression : System.Web.UI.BoundPropertyEntry * obj * System.Web.Compilation.ExpressionBuilderContext -> System.CodeDom.CodeExpression" Usage="appSettingsExpressionBuilder.GetCodeExpression (entry, parsedData, context)" />
<MemberSignature Language="C++ CLI" Value="public:
 override System::CodeDom::CodeExpression ^ GetCodeExpression(System::Web::UI::BoundPropertyEntry ^ entry, System::Object ^ parsedData, System::Web::Compilation::ExpressionBuilderContext ^ context);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.CodeDom.CodeExpression</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="entry" Type="System.Web.UI.BoundPropertyEntry" />
<Parameter Name="parsedData" Type="System.Object" />
<Parameter Name="context" Type="System.Web.Compilation.ExpressionBuilderContext" />
</Parameters>
<Docs>
<param name="entry">The property to which the expression is bound.</param>
<param name="parsedData">The object that represents parsed data as returned by <see cref="M:System.Web.Compilation.ExpressionBuilder.ParseExpression(System.String,System.Type,System.Web.Compilation.ExpressionBuilderContext)" />.</param>
<param name="context">Properties for the control or page.</param>
<summary>Returns a code expression that is used to perform the property assignment in the generated page class.</summary>
<returns>A <see cref="T:System.CodeDom.CodeExpression" /> that is used in the property assignment.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method is called during the CodeDOM creation for a page or control. The returned <xref:System.CodeDom.CodeExpression> object represents the code expression to add to the property assignment in the generated page class.
]]></format>
</remarks>
<altmember cref="P:System.Configuration.ConfigurationManager.AppSettings" />
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/d5bd1tad(v=vs.100)">ASP.NET Expressions Overview</related>
</Docs>
</Member>
<Member MemberName="SupportsEvaluate">
<MemberSignature Language="C#" Value="public override bool SupportsEvaluate { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool SupportsEvaluate" />
<MemberSignature Language="DocId" Value="P:System.Web.Compilation.AppSettingsExpressionBuilder.SupportsEvaluate" />
<MemberSignature Language="VB.NET" Value="Public Overrides ReadOnly Property SupportsEvaluate As Boolean" />
<MemberSignature Language="F#" Value="member this.SupportsEvaluate : bool" Usage="System.Web.Compilation.AppSettingsExpressionBuilder.SupportsEvaluate" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual property bool SupportsEvaluate { bool get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Returns a value indicating whether an expression can be evaluated in a page that is not compiled.</summary>
<value>
<see langword="true" /> in all cases.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.Compilation.AppSettingsExpressionBuilder.SupportsEvaluate%2A> property indicates whether the <xref:System.Web.Compilation.AppSettingsExpressionBuilder.EvaluateExpression%2A> method has been implemented in the class and can return a value for the expression. <xref:System.Web.Compilation.AppSettingsExpressionBuilder.EvaluateExpression%2A> must be implemented within an expression builder for an expression to be evaluated in a page that is not compiled. The <xref:System.Web.Compilation.AppSettingsExpressionBuilder> class supports evaluation of an application setting in a page that is not compiled, so it always returns `true`.
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.CompilationMode" />
<altmember cref="P:System.Configuration.ConfigurationManager.AppSettings" />
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/d5bd1tad(v=vs.100)">ASP.NET Expressions Overview</related>
</Docs>
</Member>
</Members>
</Type>