Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Build the method/function header
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Build the method/function header
Divers
Thread ID:
01223390
Message ID:
01223390
Vues:
55
Hi,

I have a method for handle my error and in this method I would like to reconstruct the header of the function/method that generate the error.

For that, I try to use the Reflection namespace and I have been able to do the half of what I need.

Ex :

Public Sub Main(Byval Test as string)
Try
...
Catch Ex as Exception
WriteError(System.Reflection.MethodBase.GetCurrentMethod())
End Try
End Sub

Public Sub WriteError(Byval oCurrentMethod as System.Reflection.MethodBase)
Dim lcError As String = ""

lcError &= IIf(oCurrentMethod.IsPrivate, "Private ", "Public ")
lcError &= "Sub/Function "

lcError &= oCurrentMethod.Name & "("

For liParameters As Integer = 1 To oCurrentMethod.GetParameters().Length
If liParameters > 1 Then
cError &= ", "
End If
lcError &= IIf(Right(oCurrentMethod.GetParameters(liParameters - 1).ParameterType().ToString(), 1) = "&", "ByRef ", "ByVal ")
lcError &= oCurrentMethod.GetParameters(liParameters - 1).Name & " As "
lcError &= oCurrentMethod.GetParameters(liParameters - 1).ParameterType.ToString()
lcError = IIf(Right(oCurrentMethod.GetParameters(liParameters - 1).ParameterType().ToString(), 1) = "&", lcError.Substring(0, lcError.Length - 1), lcError.Substring(0, lcError.Length))
Next
lcError &= ")"
End Sub

The result of lcError will be : Private Sub/Function Main(Byval Test as System.String)

So, I don't know how to determinate if it is a function or a method. Also, I think I miss other thing like, if it is a property or overridable ...

I don't know if there is a simple way of doing this ...

Thx!
Répondre
Fil
Voir

Click here to load this message in the networking platform