/// <summary> /// Method used to add a element into a sorted collection without destroying the sorting order. /// </summary> /// <param name="typeIndex">Index in the collection at which the link type's elements start.</param> /// <param name="collection">Sorted collection to add the new view models to.</param> /// <param name="link">Embedding relationship including the model element as the child (target).</param> /// <param name="c">View model representing the model element to be added to the collection.</param> protected virtual void InsertElement(int typeIndex, DslEditorTreeViewModel::BaseModelElementTreeViewModel parent, System.Collections.ObjectModel.ObservableCollection<DslEditorTreeViewModel::BaseModelElementTreeViewModel> collection, DslModeling::ElementLink link, DslEditorTreeViewModel::BaseModelElementTreeViewModel c) { System.Collections.ObjectModel.ReadOnlyCollection<DslModeling::ElementLink> lllinks = DslModeling::DomainRoleInfo.GetElementLinks<DslModeling::ElementLink>(parent.Element, DslEditorModeling::DomainModelElement.GetSourceDomainRole(link.GetDomainRelationship()).Id); int indexOfLink = lllinks.IndexOf(link) + typeIndex; if (indexOfLink >= collection.Count) collection.Add(c); else collection.Insert(indexOfLink, c); }