本文整理汇总了VB.NET中System.Web.Compilation.ExpressionBuilder类的典型用法代码示例。如果您正苦于以下问题:VB.NET ExpressionBuilder类的具体用法?VB.NET ExpressionBuilder怎么用?VB.NET ExpressionBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExpressionBuilder类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: MyExpressionBuilder
' 导入命名空间
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