Please how can I use a Type definition returned from a function?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Dim d = Request.Form("payload")
Dim r = JsonConvert.DeserializeObject(Of request)(d)
** this line fails: **
Dim p = JsonConvert.DeserializeObject(Of DB.ResolveType(r.req_type))(r.data)
DB.new_request(r.req_type, r.src, r.data)
Catch ex As Exception
End Try
End Sub
The function below compiles, but I get: BC30002 "Type 'DB.ResolveType' is not defined."
Public NotInheritable Class DB
Public Shared Function ResolveType(type As String) As Type
Select Case type
Case "Stop-Action-Request" : Return GetType(cheque_action)
Case "Cheque-Book-Request" : Return GetType(cheque_book_request)
Case "Confirm-Action-Request" : Return GetType(cheque_action)
Case "FX-Transfer-Request" : Return GetType(cheque_action)
Case "Mobile-Banking-Request" : Return GetType(mobile_banking_request)
Case "SMS-Alerts-Request" : Return GetType(sms_alert_request)
End Select
Return Nothing
End Function
End Class
Aucun commentaire:
Enregistrer un commentaire