///-------------------------------------------------------------------------------- /// <summary>This method sets the default values.</summary> ///-------------------------------------------------------------------------------- protected override void OnSetDefaults() { if (Feature.ReverseInstance != null) { EditFeature.TransformDataFromObject(Feature.ReverseInstance, null, false); } else if (Feature.IsAutoUpdated == true) { EditFeature.TransformDataFromObject(Feature, null, false); } else { Feature newFeature = new Feature(); newFeature.FeatureID = EditFeature.FeatureID; EditFeature.TransformDataFromObject(newFeature, null, false); } EditFeature.ResetModified(true); foreach (EntityViewModel item in Items.OfType <EntityViewModel>()) { item.Defaults(); } }
///-------------------------------------------------------------------------------- /// <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(); }
///-------------------------------------------------------------------------------- /// <summary>This method resets the data.</summary> ///-------------------------------------------------------------------------------- protected override void OnReset() { EditFeature.TransformDataFromObject(Feature, null, false); EditFeature.ResetModified(false); }