I want to implement this function:
Public Function GetFunc(Of TSource, TResult) _
selector As Expression(Of Func(Of TSource, TResult)) _
As Func(Of TSource, TResult)
'Implement here
End Function
UPDATE
I have the following issue, it's a part of a function:
Dim obj As Object = value
For Each exp In expressions
If obj Is Nothing Then Return [default]
Select Case exp.NodeType
Case ExpressionType.Call
Dim method = DirectCast(exp, MethodCallExpression)
Dim info = method.Method
If method.Object Is Nothing Then
Dim args = {obj}.Union(method.Arguments.Skip(1))
'The following line throws the exception, see details bellow
obj = info.Invoke(Nothing, args.ToArray)
Else
obj = info.Invoke(obj, method.Arguments.ToArray)
End If
Exception Details:
ArgumentException:
Object of type 'System.Linq.Expressions.Expression`1
[System.Func`3[System.Char,System.Char,System.Char]]'
cannot be converted to type
'System.Func`3[System.Char,System.Char,System.Char]'.