ResourceExpressionBuilder 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
向页分析器提供代码以便为控件属性赋值。
public ref class ResourceExpressionBuilder : System::Web::Compilation::ExpressionBuilder
public class ResourceExpressionBuilder : System.Web.Compilation.ExpressionBuilder
type ResourceExpressionBuilder = class
inherit ExpressionBuilder
Public Class ResourceExpressionBuilder
Inherits ExpressionBuilder
- 继承
下面的代码示例从资源文件检索默认货币。
<%@ Page Language="C#" UICulture="auto" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Sales Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
All prices listed in
<asp:Literal ID="Literal1" runat="server"
Text="<%$ Resources: Financial, Currency %>" />.
</div>
</form>
</body>
</html>
<%@ Page Language="VB" UICulture="auto" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Sales Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
All prices listed in
<asp:Literal ID="Literal1" runat="server"
Text="<%$ Resources: Financial, Currency %>" />.
</div>
</form>
</body>
</html>
此代码从 App_GlobalResources 目录中名为 Financial.resx
的资源文件中读取以下值。
<data name="Currency"><value xml:space="preserve">US dollars</value></data>
类 ResourceExpressionBuilder 创建代码以在执行页面时检索资源值。 资源文件通常包含针对特定语言或区域性本地化的信息。
资源表达式采用页面内的形式 <%$ Resources: ClassKey, ResourceKey %>
。 冒号 (:) 之前的表达式部分指定要使用的表达式生成器的类型,冒号后面的部分表示类名和资源键。 前面的表达式将从名为 ClassKey.resx
的 文件中检索以下值:
<data name="ResourceKey"><value xml:space="preserve">Hello!</value></data>
当页面分析程序遇到带有 前缀的 Resources
表达式时,它会创建 类的 ResourceExpressionBuilder 实例。 类 ResourceExpressionBuilder 计算表达式或生成代码以在执行页面时返回表达式的值。
如果在要编译的页面中遇到表达式,则 ResourceExpressionBuilder 对象将生成从资源文件检索指定值的代码。 如果在不会编译的页中遇到表达式,则分析页面时, ResourceExpressionBuilder 对象将从资源文件返回值。
Supports |
返回一个值,该值指示表达式是否可在使用非编译功能的页中计算。 |
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
Evaluate |
从资源文件返回值。 |
Get |
返回在页执行过程中要计算的代码表达式。 |
Get |
作为默认哈希函数。 (继承自 Object) |
Get |
获取当前实例的 Type。 (继承自 Object) |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
Parse |
返回一个表示通过分析得出的表达式的对象。 |
Parse |
返回一个表示通过分析得出的表达式的对象。 |
To |
返回表示当前对象的字符串。 (继承自 Object) |
产品 | 版本 |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |