private void ParseOption(string line) { string[] options = Regex.Split(line, @"\s"); // Skip the first element since it will still contain the "#" IEnumerable <string> optionsEnumerable = options.Skip(1); // We will manually control the enumerator here since the last item (resistance) // has to fetch the next item in sequence using var enumer = optionsEnumerable.GetEnumerator(); while (enumer.MoveNext()) { string option = enumer.Current; // Format specifies that options can occur in any order if (TouchstoneEnumMap <FrequencyUnit> .ValidTouchstoneName(option)) { //string frequencyUnitName = frequencyUnitLookup.Value[option]; Options.FrequencyUnit = TouchstoneEnumMap <FrequencyUnit> .FromTouchstoneValue(option); } else if (TouchstoneEnumMap <FormatType> .ValidTouchstoneName(option)) { Options.Format = TouchstoneEnumMap <FormatType> .FromTouchstoneValue(option); } else if (TouchstoneEnumMap <ParameterType> .ValidTouchstoneName(option)) { Options.Parameter = TouchstoneEnumMap <ParameterType> .FromTouchstoneValue(option); } else if (option == resistanceSignifier) { // For resistance, this option is specified in the format of "R [value]" // Hence, we need to actually move the enumerator forward to get the value bool success = enumer.MoveNext(); if (success) { string value = enumer.Current; bool parsed = float.TryParse(value, out float r); if (parsed) { Options.Resistance = r; } else { ThrowHelper("Options", "Bad value for resistance"); } } else { ThrowHelper("Options", "No value specified for resistance"); } } else { ThrowHelper("Options", $"Invalid option value {option}"); } } }