Tuesday, January 14, 2014

Get All Methods in a Class (VB)

Public Shared Function GetMethodInfoList(ByRef objClass As Type) As List(Of System.Reflection.MethodInfo)
'get the methods of the object.
Dim objList As New List(Of System.Reflection.MethodInfo)

Dim objClassProperties() As System.Reflection.MethodInfo 'array of methodinfo.
objClassProperties = objClass.GetMethods()

Dim objMethodItem As System.Reflection.MethodInfo

For Each mi_MethodItem In objClassProperties

Return objList
End Function

Private Shared Function GetMethodParameters(ByRef objMethodInfo As System.Reflection.MethodInfo) As List(Of MyModels.NameValue)
Dim objList As New List(Of MyModels.NameValue)

Dim objParams() As System.Reflection.ParameterInfo
objParams = objMethodInfo.GetParameters()

For Each ParamItem In objParams
Dim objNameValue As New MyModels.NameValue
objNameValue.Name = ParamItem.Name
objNameValue.Value = ParamItem.ParameterType.ToString

Return objList
End Function