public void Save(ChildContent content, int position) { SelectChildren(content); int shiftContentIndex = 0; int index; int contentLength = content.Length; for (index = 0; index < _selectedContents.Count; ++index) { if (content.StartPosition < _selectedContents[index].StartPosition) { if (_selectedContents[index].StartPosition < content.StartPosition + contentLength) /// дочерний контент { contentLength += _selectedContents[index].GetFullText().Length; content.AddChild(_selectedContents[index]); RemoveContent(shiftContentIndex, ref index); } else { _selectedContents[index].SetPreviousContent(content); break; } } else if ((shiftContentIndex < _shiftContents.Count) && (_selectedContents[index] == _shiftContents[shiftContentIndex].Content)) { ++shiftContentIndex; } } _selectedContents.Insert(index, content); _shiftContents.Insert(shiftContentIndex, new ShiftContentInfo() { Content = content, Position = position }); }
/// <summary> /// Проверка, что текущий контент содержит заданный /// </summary> /// <param name="content">заданный контент</param> /// <returns>результат проверки</returns> private bool IsContain(ChildContent content) { return((StartPosition < content.StartPosition) && (content.StartPosition < StartPosition + Length)); }