public static QuestionViewModel GetViewModelForQuestion(Question question) { Func<Question, QuestionViewModel> viewModelInstanceFactory = null; if (maps.TryGetValue(question.GetType(), out viewModelInstanceFactory)) { return viewModelInstanceFactory(question); } else { throw new ArgumentOutOfRangeException("Could not locate a view model for question type"); } }
private QuestionViewModel CreateQuestionViewModel(Question question) { QuestionViewModel vm = QuestionViewModelFactory.GetViewModelForQuestion(question); vm.ResponseChanged += this.OnQuestionResponseChanged; return vm; }