I have some instruments. Each instrument should have a name (string) and description (string).
Each instrument can have some setups, which these setups are each a series of commands(string[] or List).
I want this class to be flexible so I can easily add or remove a whole instrument, or add or remove setups for any instrument that is existing in the class.
At the end, I want to save this class in properties of my assembly so each time the program starts it can be loaded. I am also thinking about serializing it and save it on disk for moving to another copy of the software.
So please let me know what you think about this approach and if you think this can be improved or even I should consider going with another way please let me know!
namespace MeasurementSuite
{
/// <summary>
/// Setups for all instruments
/// </summary>
public class Setups
{
/// <summary>
/// An instrument
/// </summary>
public class Instrument
{
/// <summary>
/// Name of the instrument
/// </summary>
public string Name { get; set; }
/// <summary>
/// Info about the instrument
/// </summary>
public string Info { get; set; }
/// <summary>
/// List of existing setups
/// </summary>
public List<Setup> SetupList { get; set; }
/// <summary>
/// Adds a setup to the instrument
/// </summary>
/// <param name="name"></param>
/// <param name="commands"></param>
private void AddSetup(string name, string[] commands)
{
this.SetupList.Add(new Setup(name, commands));
}
/// <summary>
/// Removes a setup from the instrument
/// </summary>
/// <param name="name">Name of the setup</param>
public void RemoveSetup(string name)
{
foreach (Setup setup in SetupList)
{
if (setup.Name == name)
{
SetupList.Remove(setup);
}
}
}
}
/// <summary>
/// Setup for a instrument
/// </summary>
public class Setup
{
/// <summary>
/// Name of the setup
/// </summary>
public string Name { get; set; }
/// <summary>
/// Command sets for setup
/// </summary>
public string[] CommandSet { get; set; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="name">Setup Name</param>
/// <param name="commands">Setup Command sets</param>
public Setup(string name, string[] commands)
{
this.Name = name;
this.CommandSet = commands;
}
}
}
}

Setups.Instrument inst = new Setups.Instrument();and theninst.AddSetup("Setup1", new string[] {"Execute"});Also, you never instantiate theSetupListso trying to access it throws exceptions. maybe add it in a default constructorpublic Instrument() { SetupList = new List<Setup>();}– Dylan Yaga Nov 3 '11 at 11:06