public static ControlParser createParser(int id, string line) { ControlType type = ControlTypeExtensions.getMenuTypeFromString(line.Split('|')[ControlParser.TYPE]); switch (type) { case ControlType.SWITCH: return(new SwitchParser(id, line)); case ControlType.COMBOBOX: return(new ComboBoxParser(id, line)); case ControlType.RADIO: return(new RadioParser(id, line)); case ControlType.TEXTBOX: return(new TextboxParser(id, line)); case ControlType.SLIDER: return(new SliderParser(id, line)); default: return(null); } }
//creates the base attributes for any control //format: type|title|grouping|must_answer|extra|instructions <- the contents of "extra" will change based on what type of control it is private void processLine(string line) { string[] parts = line.Split('|'); if (parts.Length != 6 || ControlTypeExtensions.getMenuTypeFromString(parts[TYPE]) == ControlType.NONE) { throw new ArgumentException("must be formatted as type|title|grouping|must_answer|extras|instructions, where type is a valid controltype and must_answer" + "is a boolean"); } else { title = parts[TITLE]; Grouping = parts[GROUPING]; MustAnswer = generateMustAnswer(parts[MUST_ANSWER]); } }