V
Vince Castellano
Hello,
I have a set of DLLs that implement different configurations of the
same API. Consider them as first.dll, second.dll, and third.dll. They
all share a common API, calling pattern, and have the same logic to
handle the calls. Calls in the VB.net code does not call the DLLs
directly, but rather a custom dll wrapper class, so that the logic can
be made for the VB code in the abstraction class.
Initially, my idea was to create a superclass that contained
MustOverride prototypes for the DLL calls, and the VB public apis
implemented in this class. Then have 3 concrete classes FirstDll,
SecondDll, and ThirdDll, and have the Declares override the DLL api
calls, and just inherit the VB public API. This did not work however
as
you can not specify Declares as overrides.
Second, I attempted to implement the Strategy pattern, by creating an
interface called DllAPI which had the DLL prototype Declares as
methods, then create 3 concrete classes implementing the interface
with
their respective declares. Then create GlobalAPI class that contained
all the public VB APIs, and contains a reference to a DllAPI object,
which polymorphically is the proper DLL type, and delegate DLL calls
to
that object. This did not work either however as you cannot use
Declares to implement an interface.
What is the right way to do this, as to not have to maintain duplicate
VB public API information in multiple classes that are 95% the same?
Normally I would not seek asking such questions, as they are design
issues, but everything I try seems to be constrained by VB limitations
(with or without good reason), so I am hoping someone else has solved
this issue.
Thank you,
Vincent Castellano
I have a set of DLLs that implement different configurations of the
same API. Consider them as first.dll, second.dll, and third.dll. They
all share a common API, calling pattern, and have the same logic to
handle the calls. Calls in the VB.net code does not call the DLLs
directly, but rather a custom dll wrapper class, so that the logic can
be made for the VB code in the abstraction class.
Initially, my idea was to create a superclass that contained
MustOverride prototypes for the DLL calls, and the VB public apis
implemented in this class. Then have 3 concrete classes FirstDll,
SecondDll, and ThirdDll, and have the Declares override the DLL api
calls, and just inherit the VB public API. This did not work however
as
you can not specify Declares as overrides.
Second, I attempted to implement the Strategy pattern, by creating an
interface called DllAPI which had the DLL prototype Declares as
methods, then create 3 concrete classes implementing the interface
with
their respective declares. Then create GlobalAPI class that contained
all the public VB APIs, and contains a reference to a DllAPI object,
which polymorphically is the proper DLL type, and delegate DLL calls
to
that object. This did not work either however as you cannot use
Declares to implement an interface.
What is the right way to do this, as to not have to maintain duplicate
VB public API information in multiple classes that are 95% the same?
Normally I would not seek asking such questions, as they are design
issues, but everything I try seems to be constrained by VB limitations
(with or without good reason), so I am hoping someone else has solved
this issue.
Thank you,
Vincent Castellano