I have an IA interface. Adapter B implements this interface. IZ is an interface that is implemented by the classes X , Y, and Z. IA is the interface with which my application negotiates with X, Y, and Z using adapter B. B contains an IZ instance (adapter template). Now, from adapter B, I want to access functions that are unique to X, but since it is connected to the IZ interface in the adapter, how can I access this function using clean ? Also, the IZ instance in adapter B is determined at run time based on some manual user activity. Is there a way that I can use dependency injection to create an IZ instance in adapter B (I want to avoid using the new operator)?
IA
|
B (has an IZ instance)
IZ
/ | \
Xyz
EDIT: There is a good chance that X ', Y', Z 'can get into the picture ... all with one IZ interface, but Y' can have one method (maybe not the same as X) that is required accessible from B. Both unique methods Y 'and X will adapt to some common method M in interface IA
I have no control over X, Y and Z or X ', Y', Z ', except that they can implement the IZ interface. But I have control over IA and B. I used the adapter template mainly so that new classes can adapt to my IA interface
source share