public Question PopQuestion(IQuestionKey keyToUseForReference) { ResolveDeletionsAndAdditions(); PhraseCustomization questionToInsert; try { questionToInsert = AdditionsAndInsertions.First(); } catch (Exception e) { throw new InvalidOperationException("PopQuestion should only be called for a customization that is not tied to any other question and has " + "at least one insertion or addition.", e); } AdditionsAndInsertions.RemoveAt(0); var newQ = new Question(keyToUseForReference.ScriptureReference, keyToUseForReference.StartRef, keyToUseForReference.EndRef, questionToInsert.ModifiedPhrase ?? questionToInsert.OriginalPhrase, questionToInsert.Answer); SetExcludedAndModified(newQ); if (AllAnswers != null && AllAnswers.Any()) // Note: If there are any, there are at least 2 { newQ.Answers = AllAnswers.ToArray(); } return(newQ); }
private void RemoveAddition(int iAdditionToRemove) { var answer = AdditionsAndInsertions[iAdditionToRemove].Answer; AdditionsAndInsertions.RemoveAt(iAdditionToRemove); if (!String.IsNullOrWhiteSpace(answer) && !AllAnswers.Any(a => a.Contains(answer)) && !AdditionsAndInsertions.Where(b => b.Answer != null).Any(c => c.Answer.Contains(answer))) { AllAnswers.Add(answer); } }