Bagikan melalui


ExpressionBuilder.GetCodeExpression Metode

Definisi

Saat ditimpa di kelas turunan, mengembalikan kode yang digunakan selama eksekusi halaman untuk mendapatkan ekspresi yang dievaluasi.

public:
 abstract System::CodeDom::CodeExpression ^ GetCodeExpression(System::Web::UI::BoundPropertyEntry ^ entry, System::Object ^ parsedData, System::Web::Compilation::ExpressionBuilderContext ^ context);
public abstract System.CodeDom.CodeExpression GetCodeExpression (System.Web.UI.BoundPropertyEntry entry, object parsedData, System.Web.Compilation.ExpressionBuilderContext context);
abstract member GetCodeExpression : System.Web.UI.BoundPropertyEntry * obj * System.Web.Compilation.ExpressionBuilderContext -> System.CodeDom.CodeExpression
Public MustOverride Function GetCodeExpression (entry As BoundPropertyEntry, parsedData As Object, context As ExpressionBuilderContext) As CodeExpression

Parameter

entry
BoundPropertyEntry

Objek yang mewakili informasi tentang properti yang terikat oleh ekspresi.

parsedData
Object

Objek yang berisi data yang diurai seperti yang dikembalikan oleh ParseExpression(String, Type, ExpressionBuilderContext).

context
ExpressionBuilderContext

Informasi kontekstual untuk evaluasi ekspresi.

Mengembalikan

CodeExpression yang digunakan untuk penetapan properti.

Contoh

Contoh kode berikut menunjukkan cara mengembalikan CodeExpression objek dengan mengesampingkan GetCodeExpression metode .

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 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

Keterangan

Kelas yang mewarisi dari ExpressionBuilder kelas harus menerapkan GetCodeExpression metode abstrak.

Catatan Bagi Implementer

Jika Anda menerapkan penyusun ekspresi kustom, Anda harus melakukan transmisi jenis yang tepat untuk properti kontrol dan mengembalikan operasi transmisi dalam CodeExpression objek.

Berlaku untuk