public void ReplaceWordsBy(Func<IWord, bool> predicate, string replaceString, IFactory<string, IEnumerable<IPartOfSentence>> parser) { var newParts = parser.Construct(replaceString); var newSentence = new List<IPartOfSentence>(); foreach (var part in Items) { if (part is IWord) { if (predicate(part as IWord)) { newSentence.AddRange(newParts); continue; } } newSentence.Add(part); } Items = newSentence.AsEnumerable(); }