Inherits System.Web.UI.Page '
Private type As Type = Nothing
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
type = GetType(InstanceClass)
End Sub
Protected Function getObjectProperty(ByVal str As String) As String
Dim retValue As String = ""
Try
Dim o As Object = Activator.CreateInstance(type, New Object() {Me.txtPropertyValue.Text.Trim()})
Dim pi As PropertyInfo = type.GetProperty("ReturnValue", GetType(String))
retValue = pi.GetValue(o, Nothing).ToString()
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Return retValue
End Function
Protected Function getOjbectMethod(ByVal str As String) As String
Dim retValue As Object = Nothing
Try
Dim o As Object = Activator.CreateInstance(type)
Dim mi As MethodInfo = type.GetMethod("getFunction", BindingFlags.Public Or BindingFlags.Instance, Nothing, New Type() {GetType(String)}, Nothing)
retValue = mi.Invoke(o, New Object() {str})
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Return retValue.ToString()
End Function
Protected Sub btnGetProperty_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.lblPropertyResult.Text = Me.getObjectProperty(Me.txtPropertyValue.Text.Trim())
End Sub
Protected Sub btnInvoke_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.lblInvokeResult.Text = Me.getOjbectMethod(Me.txtParameter.Text.Trim())
End Sub
End Class