I am working to create a C# library that wraps a C DLL to integrate with our test system. The C DLL has probably close to 100 functions that can be accessed and all from the same DLL. I don't need all functions wrapped at this time, but I want to ensure I am setup in a direction that makes implementing everything maintainable.
The DLL 'groups' many of its functions under different purposes to help create separation. My plan was to create a class that is the main access point that contains generic functions and then create separate classes that create extension methods for the generic class.
Lets say my 'groups' are:
- Generic
- Acquisition
- Selection
- Interaction
- Utilities
I would then create my main class
public class BaseClass
{
// Generic methods
}
Then the other groups would each be their own static extension class:
public static class AcquisitionClassExtensions
{
public static int AcquisitionMethod1(this BaseClass b)
{
// Access DLL
}
}
And continue for the other groups. This would let me keep the BaseClass as the main object class that the DLL would be interacted with.
The user would still see a huge list of methods when viewing intellisense, but from a project maintainability I can keep things separate. I am sure i would run in to problems if one of the extension methods ends of needing some sort of state tracked, but that is minimal.
Is there a better way i could approach this or am i worrying about nothing?
Clarity Edit:
The generic group or BaseClass
contains the basic connection access to the hardware system that the DLL is for, and that would maintain state. The other groups are special operations that can be performed on the hardware. The goal being if a new set of functionality is added it can be added with the extension methods like the other groupings.
BaseClass
-- I couldn't fully understand what was meant byGeneric methods
in this context (generic part confused me a bit), but it seems likeBaseClass
is the sole one accessing the DLL (and therefore quite monolithic). Then you organize access to this rather monolithicBaseClass
through various classes with static methods? Is that correct?