///-------------------------------------------------------------------------------- /// <summary>This method updates the view model data and sends update command back /// to the solution builder.</summary> ///-------------------------------------------------------------------------------- protected override void OnUpdate() { // send update for any updated children foreach (EntityReferenceViewModel item in EntityReferences) { if (item.IsEdited == true) { item.Update(); } } // send update for any new children foreach (EntityReferenceViewModel item in ItemsToAdd.OfType <EntityReferenceViewModel>()) { item.Update(); EntityReferences.Add(item); } ItemsToAdd.Clear(); // send delete for any deleted children foreach (EntityReferenceViewModel item in ItemsToDelete.OfType <EntityReferenceViewModel>()) { item.Delete(); EntityReferences.Remove(item); } ItemsToDelete.Clear(); // reset modified for children foreach (EntityReferenceViewModel item in EntityReferences) { item.ResetModified(false); } }
///-------------------------------------------------------------------------------- /// <summary>This method updates the view model data and sends update command back /// to the solution builder.</summary> ///-------------------------------------------------------------------------------- protected override void OnUpdate() { // send update for any updated children foreach (StageTransitionViewModel item in StageTransitions) { if (item.IsEdited == true) { item.Update(); } } // send update for any new children foreach (StageTransitionViewModel item in ItemsToAdd.OfType <StageTransitionViewModel>()) { item.Update(); StageTransitions.Add(item); } ItemsToAdd.Clear(); // send delete for any deleted children foreach (StageTransitionViewModel item in ItemsToDelete.OfType <StageTransitionViewModel>()) { item.Delete(); StageTransitions.Remove(item); } ItemsToDelete.Clear(); // reset modified for children foreach (StageTransitionViewModel item in StageTransitions) { item.ResetModified(false); } }
///-------------------------------------------------------------------------------- /// <summary>This method adds relationships for an entity to the view model.</summary> /// /// <param name="entity">The entity to add.</param> ///-------------------------------------------------------------------------------- public void AddRelationships(DiagramEntityViewModel diagramEntity) { NameObjectCollection relationshipsAdded = new NameObjectCollection(); // add relationships this entity is the source of foreach (Relationship relationship in diagramEntity.EntityViewModel.Entity.RelationshipList) { bool isDeletedRelationship = false; foreach (DiagramRelationshipViewModel diagramRelationship in ItemsToDelete.OfType <DiagramRelationshipViewModel>()) { if (diagramRelationship.RelationshipViewModel.Relationship.RelationshipID == relationship.RelationshipID) { isDeletedRelationship = true; break; } } if (isDeletedRelationship == false && relationshipsAdded[relationship.RelationshipID.ToString()] == null) { foreach (DiagramEntityViewModel loopEntity in DiagramEntities) { if (relationship.ReferencedEntityID == loopEntity.EntityViewModel.Entity.EntityID) { RelationshipViewModel relationshipViewModel = new RelationshipViewModel(relationship, Solution); AddRelationship(diagramEntity, loopEntity, relationshipViewModel); relationshipsAdded[relationship.RelationshipID.ToString()] = true; } } } } // add relationships this entity is the sink of foreach (DiagramEntityViewModel loopEntity in DiagramEntities) { foreach (Relationship relationship in loopEntity.EntityViewModel.Entity.RelationshipList) { if (relationship.ReferencedEntityID == diagramEntity.EntityViewModel.Entity.EntityID) { bool isDeletedRelationship = false; foreach (DiagramRelationshipViewModel diagramRelationship in ItemsToDelete.OfType <DiagramRelationshipViewModel>()) { if (diagramRelationship.RelationshipViewModel.Relationship.RelationshipID == relationship.RelationshipID) { isDeletedRelationship = true; break; } } if (isDeletedRelationship == false && relationshipsAdded[relationship.RelationshipID.ToString()] == null) { RelationshipViewModel relationshipViewModel = new RelationshipViewModel(relationship, Solution); AddRelationship(loopEntity, diagramEntity, relationshipViewModel); relationshipsAdded[relationship.RelationshipID.ToString()] = true; } } } } Refresh(false); }
///-------------------------------------------------------------------------------- /// <summary>This method updates the view model data and sends update command back /// to the solution builder.</summary> ///-------------------------------------------------------------------------------- protected override void OnUpdate() { // set up reverse engineering instance if not present if (Feature.ReverseInstance == null && Feature.IsAutoUpdated == true) { Feature.ReverseInstance = new Feature(); Feature.ReverseInstance.TransformDataFromObject(Feature, null, false); // perform the update of EditFeature back to Feature Feature.TransformDataFromObject(EditFeature, null, false); Feature.IsAutoUpdated = false; } else if (Feature.ReverseInstance != null) { EditFeature.ResetModified(Feature.ReverseInstance.IsModified); if (EditFeature.Equals(Feature.ReverseInstance)) { // perform the update of EditFeature back to Feature Feature.TransformDataFromObject(EditFeature, null, false); Feature.IsAutoUpdated = true; } else { // perform the update of EditFeature back to Feature Feature.TransformDataFromObject(EditFeature, null, false); Feature.IsAutoUpdated = false; } } else { // perform the update of EditFeature back to Feature Feature.TransformDataFromObject(EditFeature, null, false); Feature.IsAutoUpdated = false; } Feature.ForwardInstance = null; if (FeatureNameCustomized || DescriptionCustomized || TagsCustomized) { Feature.ForwardInstance = new Feature(); Feature.ForwardInstance.FeatureID = EditFeature.FeatureID; Feature.SpecSourceName = Feature.DefaultSourceName; if (FeatureNameCustomized) { Feature.ForwardInstance.FeatureName = EditFeature.FeatureName; } if (DescriptionCustomized) { Feature.ForwardInstance.Description = EditFeature.Description; } if (TagsCustomized) { Feature.ForwardInstance.Tags = EditFeature.Tags; } } EditFeature.ResetModified(false); OnUpdated(this, null); // send update back to solution builder SendEditFeaturePerformed(); // send update for any updated Entities foreach (EntityViewModel item in Entities) { if (item.IsEdited == true) { item.Update(); } } // send update for any new Entities foreach (EntityViewModel item in ItemsToAdd.OfType <EntityViewModel>()) { item.Update(); Entities.Add(item); } // send delete for any deleted Entities foreach (EntityViewModel item in ItemsToDelete.OfType <EntityViewModel>()) { item.Delete(); Entities.Remove(item); } // reset modified for Entities foreach (EntityViewModel item in Entities) { item.ResetModified(false); } ItemsToAdd.Clear(); ItemsToDelete.Clear(); }