ExpressionPrefixAttribute クラス
アセンブリ: System.Web (system.web.dll 内)

<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple:=False)> _ Public NotInheritable Class ExpressionPrefixAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=false)] public sealed class ExpressionPrefixAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple=false)] public ref class ExpressionPrefixAttribute sealed : public Attribute

ExpressionPrefixAttribute クラスは、構成ファイルに定義されない式について設計時に使用します。ExpressionPrefix プロパティを使用して、ExpressionPrefixAttribute オブジェクトに関連付けられているプレフィックスの名前を取得します。式ビルダは、次の形式のステートメントを検索します。
<%$ [expressionPrefix]:[expressionValue] %>
次に式ビルダは、式のプレフィックスに基づいて、プロパティを割り当てるためのコードを生成します。expressionPrefix パラメータは、構成済みの式ビルダを参照します。構成済みの式ビルダは、構成ファイルまたは ExpressionPrefixAttribute オブジェクトを使用して定義されます。

ExpressionPrefixAttribute クラスを使用する方法を次のコード例に示します。属性は、ExpressionBuilder 抽象クラスを実装するカスタム式ビルダに適用されます。この ExpressionBuilder 実装は、式に渡される評価済みステートメントを返します。この例を実行するには、あらかじめカスタム式ビルダを Web.config ファイルに登録しておく必要があります。最初のコード例に、カスタム式ビルダを Web.config ファイルに登録する方法を示します。
<configuration> <system.web> <compilation> <expressionBuilders> <add expressionPrefix="MyCustomExpression" type="MyCustomExpressionBuilder"/> </expressionBuilders> </compilation> </system.web> </configuration>
2 番目のコード例に、.aspx ファイルに含まれている式を参照する方法を示します。
<asp:Label ID="Label1" runat="server" Text="<%$ MyCustomExpression:Hello, world! %>" />
3 番目のコード例に、ExpressionBuilder から派生させて、カスタマイズされた式ビルダを開発する方法を示します。このコード例を実行するには、クラスを App_Code フォルダに配置する必要があります。
Imports System Imports System.CodeDom Imports System.Web.UI Imports System.ComponentModel Imports System.Web.Compilation Imports System.Web.UI.Design ' Apply ExpressionEditorAttributes to allow the ' expression to appear in the designer. <ExpressionPrefix("MyCustomExpression")> _ <ExpressionEditor("MyCustomExpressionEditor")> _ Public Class MyExpressionBuilder Inherits ExpressionBuilder ' Create a method that will return the result ' set for the expression argument. Public Shared Function GetEvalData(ByVal expression As String, _ ByVal target As Type, ByVal entry As String) As Object Return expression End Function Public Overrides Function EvaluateExpression(ByVal target As Object, _ ByVal entry As BoundPropertyEntry, ByVal parsedData As Object, _ ByVal context As ExpressionBuilderContext) As Object Return GetEvalData(entry.Expression, target.GetType(), entry.Name) End Function Public Overrides Function GetCodeExpression(ByVal entry _ As BoundPropertyEntry, ByVal parsedData As Object, ByVal context _ As ExpressionBuilderContext) As CodeExpression Dim type1 As Type = entry.DeclaringType Dim descriptor1 As PropertyDescriptor = _ TypeDescriptor.GetProperties(type1)(entry.PropertyInfo.Name) Dim expressionArray1(2) As CodeExpression expressionArray1(0) = New CodePrimitiveExpression(entry.Expression.Trim()) expressionArray1(1) = New CodeTypeOfExpression(type1) expressionArray1(2) = New CodePrimitiveExpression(entry.Name) Return New CodeCastExpression(descriptor1.PropertyType, _ New CodeMethodInvokeExpression(New CodeTypeReferenceExpression _ (MyBase.GetType()), "GetEvalData", expressionArray1)) End Function Public Overrides ReadOnly Property SupportsEvaluate() As Boolean Get Return True End Get End Property End Class
using System; using System.CodeDom; using System.Web.UI; using System.ComponentModel; using System.Web.Compilation; using System.Web.UI.Design; // Apply ExpressionEditorAttributes to allow the // expression to appear in the designer. [ExpressionPrefix("MyCustomExpression")] [ExpressionEditor("MyCustomExpressionEditor")] public class MyExpressionBuilder : ExpressionBuilder { // Create a method that will return the result // set for the expression argument. public static object GetEvalData(string expression, Type target, string entry) { return expression; } public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context) { return GetEvalData(entry.Expression, target.GetType(), entry.Name); } public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context) { Type type1 = entry.DeclaringType; PropertyDescriptor descriptor1 = TypeDescriptor.GetProperties(type1)[entry.PropertyInfo.Name]; CodeExpression[] expressionArray1 = new CodeExpression[3]; expressionArray1[0] = new CodePrimitiveExpression(entry.Expression.Trim()); expressionArray1[1] = new CodeTypeOfExpression(type1); expressionArray1[2] = new CodePrimitiveExpression(entry.Name); return new CodeCastExpression(descriptor1.PropertyType, new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(base.GetType()), "GetEvalData", expressionArray1)); } public override bool SupportsEvaluate { get { return true; } } }

System.Attribute
System.Web.Compilation.ExpressionPrefixAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ExpressionPrefixAttribute コンストラクタ
アセンブリ: System.Web (system.web.dll 内)


プレフィックス識別子を使用して ExpressionPrefixAttribute クラスのインスタンスを初期化するには、ExpressionPrefixAttribute コンストラクタを使用します。ExpressionPrefixAttribute は、ExpressionPrefixAttribute クラスの既定のコンストラクタです。

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ExpressionPrefixAttribute プロパティ

名前 | 説明 | |
---|---|---|
![]() | ExpressionPrefix | 現在の ExpressionBuilder オブジェクトのプレフィックス値を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |

ExpressionPrefixAttribute メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

ExpressionPrefixAttribute メンバ
式ビルダで使用するプレフィックス属性を指定します。このクラスは継承できません。
ExpressionPrefixAttribute データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | ExpressionPrefix | 現在の ExpressionBuilder オブジェクトのプレフィックス値を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からExpressionPrefixAttributeを検索する場合は、下記のリンクをクリックしてください。

- ExpressionPrefixAttributeのページへのリンク