Hi All,
I'm in a situation I need to Expose an object.
the object I need to expose in a namespace I'm not allowed to reference directly as the application is modular and the module can be loaded or not.
In a class I've got this Propperty and function:
How can I enforce that the object has these interfaces in this line?Code:Public Property ObjectToExpose As Object Implements IExposedObject.ObjectToExpose Get Return _ObjectToExpose End Get Set(value As Object) If value IsNot Nothing Then If HasInterfaces(value) Then _ObjectToExpose = value _id = value.id Else Throw New Exception("Item doesn't support Idirty or IselectionListData") End If End If End Set End Property Private Function HasInterfaces(ByVal Item As Object) As Boolean Dim SelctionInterface As String = "ISelectionListData" Dim DirtyInterface As String = "IDirty" Dim result As Boolean If Item.GetType.GetInterface(DirtyInterface) IsNot Nothing Then result = (Item.GetType.GetInterface(SelctionInterface) IsNot Nothing) End If Return result End Function
Public Property ObjectToExpose As Object
Something like:
Public Property (T as {"Idrty","ISelectionListData"}) ObjectToExpose As Object




Reply With Quote