private static State FindStartState(Machine machine, ITranslationErrorHandler handler) { bool foundStartState = false; foreach (State state in machine.AllStates()) { if (state == machine.StartState || state.IsStart) { if (!foundStartState) { foundStartState = true; } else { throw handler.TwoStartStates(machine, state); } } } Debug.Assert(!(foundStartState && machine.StartState == null), "machine has unregistered start state"); if (!foundStartState || machine.StartState == null) { throw handler.MissingStartState(machine); } return(machine.StartState); }