///--------------------------------------------------------------------------------
        /// <summary>This method adds a relationship to the view model.</summary>
        ///
        /// <param name="relationship">The relationship to add.</param>
        ///--------------------------------------------------------------------------------
        public void DeleteRelationship(DiagramRelationshipViewModel relationship)
        {
            // remove diagram relationship from solution diagram
            RemoveRelationship(relationship);

            // add to deleted relationship list
            ItemsToDelete.Add(relationship);
            Refresh(false);
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method deletes an entity from the view model and solution.</summary>
        ///
        /// <param name="entity">The entity to remove.</param>
        ///--------------------------------------------------------------------------------
        public void DeleteEntity(DiagramEntityViewModel entity)
        {
            // remove diagram entity
            RemoveEntity(entity, true);

            // add to deleted entity list
            ItemsToDelete.Add(entity);
            Refresh(false);
        }
Ejemplo n.º 3
0
        public AddsEditsDeletesSet(
            List <TItem> oldItems,
            List <TItem> newItems,
            Func <TItem, object> keySelector,
            Func <TItem, TItem, bool> itemsAreEqualComparer,
            Func <TItem, bool> itemCannotBeDeletedSelector = null)
        {
            OldItems = oldItems;
            NewItems = newItems;

            foreach (TItem newItem in newItems)
            {
                object newItemKey      = keySelector(newItem);
                TItem  matchingOldItem = oldItems.FirstOrDefault(oldItem => keySelector(oldItem).Equals(newItemKey));

                if (matchingOldItem == null)
                {
                    // No matching old item - this is a new item
                    ItemsToAdd.Add(newItem);
                }
                else
                {
                    // Found a matching old item
                    if (itemsAreEqualComparer(newItem, matchingOldItem))
                    {
                        // Items match - the item has not been changed
                        ItemsWithNoChanges.Add(new OldAndNew <TItem> {
                            Old = matchingOldItem, New = newItem
                        });
                    }
                    else
                    {
                        // Items don't match - there are changes
                        ItemsToChange.Add(new OldAndNew <TItem> {
                            Old = matchingOldItem, New = newItem
                        });
                    }
                }
            }

            foreach (TItem oldItem in oldItems)
            {
                object oldItemKey      = keySelector(oldItem);
                TItem  matchingNewItem = newItems.FirstOrDefault(newItem => keySelector(newItem).Equals(oldItemKey));

                if (matchingNewItem == null)
                {
                    // No matching new item - this item has been deleted
                    ItemsToDelete.Add(oldItem);
                }
            }

            if (itemCannotBeDeletedSelector != null)
            {
                ItemsThatCannotBeDeleted = ItemsToDelete.Where(itemCannotBeDeletedSelector).ToList();
            }
        }
Ejemplo n.º 4
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method puts an item into the delete queue.</summary>
 ///
 /// <param name="item">The item to delete.</param>
 ///--------------------------------------------------------------------------------
 public virtual void Delete(WorkspaceViewModel item)
 {
     ItemsToDelete.Add(item);
     Items.Remove(item);
 }
Ejemplo n.º 5
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds to PropertyInstance deletes.</summary>
 ///--------------------------------------------------------------------------------
 public void AddToDeletedPropertyInstances(PropertyInstanceViewModel item)
 {
     ItemsToDelete.Add(item);
     Items.Remove(item);
 }
Ejemplo n.º 6
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds to Entity deletes.</summary>
 ///--------------------------------------------------------------------------------
 public void AddToDeletedEntities(EntityViewModel item)
 {
     ItemsToDelete.Add(item);
     Items.Remove(item);
 }