kendolondon
asked on
Getting type of anonymous interface
Given an interface like this:
And a class implementing the interface like this...
How can I externally establish the anonymous type that the class supports. I.e. I want to do something like.
Or to put it another way, if I had an object of type spSimpleResult, how would I go about finding, through code at runtime, a type that supports the interface IResultOf(Of spSimpleResult)
I hope that is clear!!!
Thanks in advance, Kenny
Public Interface IResultOf(Of T As spBaseResult)
Sub SetData(ByVal data As T)
End Interface
And a class implementing the interface like this...
Public Class ucStandardResult
Implements IResultOf(Of spSimpleResult)
Public Sub SetData(data As spSimpleResult) Implements IResultOf(Of spSimpleResult).SetData
End Sub
End Class
How can I externally establish the anonymous type that the class supports. I.e. I want to do something like.
If GetType(IResultOf(of spSimpleResult)).IsAssignableFrom(Instance.GetType) then....
Or to put it another way, if I had an object of type spSimpleResult, how would I go about finding, through code at runtime, a type that supports the interface IResultOf(Of spSimpleResult)
I hope that is clear!!!
Thanks in advance, Kenny
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The proposed answer is only partially correct. is works this way in C#; it does not work this way in VB.NET. The VB.NET equivalent to C#'s is would be the TypeOf operator.