ResourceExpressionBuilder 类

定义

向页分析器提供代码以便为控件属性赋值。

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
继承
ResourceExpressionBuilder

示例

下面的代码示例从资源文件检索默认货币。

<%@ 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 对象将从资源文件返回值。

构造函数

ResourceExpressionBuilder()

初始化 ResourceExpressionBuilder 类的新实例。

属性

SupportsEvaluate

返回一个值,该值指示表达式是否可在使用非编译功能的页中计算。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
EvaluateExpression(Object, BoundPropertyEntry, Object, ExpressionBuilderContext)

从资源文件返回值。

GetCodeExpression(BoundPropertyEntry, Object, ExpressionBuilderContext)

返回在页执行过程中要计算的代码表达式。

GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ParseExpression(String)

返回一个表示通过分析得出的表达式的对象。

ParseExpression(String, Type, ExpressionBuilderContext)

返回一个表示通过分析得出的表达式的对象。

ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅