views:

41

answers:

0

I have two interfaces:

Interface iContact
    Property ContactID As String
    Function Services() As System.Linq.IQueryable(Of iService)
End Interface

Interface iService
    Property ServiceID As String
End Interface

I have a host app that implements these (properties skipped for brevity):

Class Contact
    Inherits iContact

    Function Service() As System.Linq.IQueryable(Of iService)
        Dim Records = _
        From S In DB.Services _
        Where S.ContactID.Equals(ContactID) _
        Select New Service With {.ServiceID = T.ServiceID}
        Return Records
     End Function
End Class

Class Service
    Inherits iService
End Class

These will be used in plug-ins in various ways, for example

Class MyOtherPluginDll

    Public Sub ProcessContact(ByRef C as iContact)
        Trace.WriteLine(C.ContactID)
    End Sub

End Class


My problem is how to get a function defined in an Interface to return a particular value. Assuming that the host implementation of iContact retrieves a bunch of "Contact" objects from a database, how do I get those into the plugin? I do not have visibility to the Host's implementation "Service" of "iService". The following therefore doesn't work

Class MyOtherPluginDll

    Public Sub ProcessContact(ByRef C as iContact)
        Trace.WriteLine(C.ContactID)

        For Each S As iService In C.Services()
            ''# Can't get here, because C.Services() returns an actual Service, not an iService
        Next

    End Sub

End Class