I want to develop a library for communicating with a circuit via serial port. This circuit understands roughly 100 serial commands and returns a response string.
The commands are divided into 3 categories (settings, environment, and outputs) so I would like to use properties or some other means to nest the categories and methods within the overall class. Instead of throwing all the command methods under a single class, what would be the recommended way to nest them? I want to avoid the following at all costs, it would just be a mess:
public class CircuitLib
{
...
// Methods.
public string SettingCommand1(string command) {...}
...
public string SettingCommand30(string command) {...}
public string EnvironmentCommand1(string command) {...}
...
public string EnvironmentCommand30(string command) {...}
public string OutputCommand1(string command) {...}
...
public string OutputCommand30(string command) {...}
}
It would be nice to be able to use properties to get to the specified category:
circuitLibInstance.GetSettingsProperty.OneOfTheSettingsMethods(stringCommand);
Any guidance would be GREATLY appreciated.
Thanks Everyone!
Well you could have:
Then:
Is that what you were after?
Of course if all your command methods actually have the same structure, you might potentially want an enum, for example:
then:
and use as: