//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors /// <summary> /// </summary> /// <param name="owner"> /// Owner of this TextElementCollection. /// In case when a collection is created for children of a parent, owner is the parent object. /// In case when a collection is created as a sibling collection of a TextElement, owner is that TextElement object. /// This distinction is very important, so that a collection belongs semantically to the owner it was created for. /// </param> /// <param name="isOwnerParent"> /// Flag indicating if the owner is a parent of objects in this collection or is a member object. /// </param> internal TextElementCollection(DependencyObject owner, bool isOwnerParent) { if (isOwnerParent) { Invariant.Assert(owner is TextElement || owner is FlowDocument || owner is TextBlock); } else { Invariant.Assert(owner is TextElement); } _owner = owner; _isOwnerParent = isOwnerParent; _indexCache = new ElementIndexCache(-1, null); }
// Sets the element/index cache. private void SetCache(int index, TextElementType item) { _indexCache = new ElementIndexCache(index, item); TextElementCollectionHelper.MarkClean(this.Parent, this); }