I have a number of objects that I need to create and add to an array. However the code below seems dirty and difficult to maintain in the long run. What I'm thinking is, I should store the Name and Value properties in a table and build each comCommand object at runtime.
However, I'm not exactly sure what the best method to about doing this... Reflection, Activator.CreateInstance or some kind of object factory?
Thanks in advance.
var engine = new comCommand() { commandName = "-e", commandValue = "PNetTNative" };
var outputFile = new comCommand() { commandName = "-f", commandValue = OutputFile };
var groupSize = new comCommand() { commandName = "-GroupSizeParamInput1ParamsIn", commandValue = GroupSize };
var pagesPerSheet = new comCommand() { commandName = "-PagesPerSheetParamInput1ParamsIn", commandValue = PagesPerSheet };
var outputFileName = new comCommand { commandName = "-OutputFileNameParamInput1ParamsIn", commandValue = OutputFileName };
var duplex = new comCommand { commandName = "-DuplexParamInput1ParamsIn", commandValue = Duplex };
var processId = new comCommand { commandName = "-ProcessIDParamInput1ParamsIn", commandValue = ProcessID };
var request = new comRunWorkFlowReq();
request.command = new[] { engine, outputFile, groupSize, pagesPerSheet, outputFileName, duplex, processId };