I am looking for some thoughts / opinions on architecture for a code layer that calls methods in the API. In my case, the call code is C # /. NET, and the API is part of an unmanaged obsolete DLL. But the same question can be applied in many different languages / environments.
I mainly write a managed wrapper around an unmanaged API. A wrapper exists to handle marshaling to unmanaged code and to convert lower-level errors and exceptions to managed exceptions.
The following pattern is often repeated, i.e. for each API function:
public void CallMethodX(<params>)
{
try
{
API.MethodX(<params);
<common code for checking for error conditions in API; convert to exceptions and throw>
<common code for logging API call>
{
catch (SEHException xx)
{
<common code for querying API for more info on error and creating new managed exception>
}
}
Also note: different API methods may have different signatures.
: . , .. , API .
, , :
, . . [ , / /.)
. [ , , , , ]
? OO , ? , , , , API .