/// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(NMF.Models.IModelElement item)
 {
     if ((this._parent.Origin == null))
     {
         IElementaryChange originCasted = item.As <IElementaryChange>();
         if ((originCasted != null))
         {
             this._parent.Origin = originCasted;
             return;
         }
     }
 }
Exemple #2
0
        private void ConnectInsertionsAndDeletions(List <IModelChange> list)
        {
            for (int i = list.Count - 1; i >= 0; i--)
            {
                IElementaryChange elementary = list[i] as IElementaryChange;
                if (elementary != null && elementary.AffectedElement != null && elementSources.ContainsKey(elementary.AffectedElement))
                {
                    list.RemoveAt(i);
                }
                else
                {
                    var t = list[i] as IChangeTransaction;
                    if (t != null && t.NestedChanges.Count == 1)
                    {
                    }
                }
            }
            int currentIndex = 0;

            while (currentIndex < list.Count)
            {
                ICompositionDeletion deletion = list[currentIndex] as ICompositionDeletion;
                if (deletion != null && deletion.DeletedElement.Parent != null)
                {
                    ElementSourceInfo sourceInfo;
                    if (elementSources.TryGetValue(deletion.DeletedElement, out sourceInfo))
                    {
                        elementSources.Remove(deletion.DeletedElement);
                        foreach (var item in deletion.DeletedElement.Descendants())
                        {
                            elementSources.Remove(item);
                        }
                        list.RemoveAt(currentIndex);
                        continue;
                    }
                    if (currentIndex < list.Count)
                    {
                        TryEliminateDeletion(list, ref currentIndex, deletion);
                    }
                }
                currentIndex++;
            }
        }