예제 #1
0
        ///--------------------------------------------------------------------------------
        /// <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 (Model.ReverseInstance == null && Model.IsAutoUpdated == true)
            {
                Model.ReverseInstance = new Model();
                Model.ReverseInstance.TransformDataFromObject(Model, null, false);

                // perform the update of EditModel back to Model
                Model.TransformDataFromObject(EditModel, null, false);
                Model.IsAutoUpdated = false;
            }
            else if (Model.ReverseInstance != null)
            {
                EditModel.ResetModified(Model.ReverseInstance.IsModified);
                if (EditModel.Equals(Model.ReverseInstance))
                {
                    // perform the update of EditModel back to Model
                    Model.TransformDataFromObject(EditModel, null, false);
                    Model.IsAutoUpdated = true;
                }
                else
                {
                    // perform the update of EditModel back to Model
                    Model.TransformDataFromObject(EditModel, null, false);
                    Model.IsAutoUpdated = false;
                }
            }
            else
            {
                // perform the update of EditModel back to Model
                Model.TransformDataFromObject(EditModel, null, false);
                Model.IsAutoUpdated = false;
            }
            Model.ForwardInstance = null;
            if (ModelNameCustomized || DescriptionCustomized || TagsCustomized)
            {
                Model.ForwardInstance         = new Model();
                Model.ForwardInstance.ModelID = EditModel.ModelID;
                Model.SpecSourceName          = Model.DefaultSourceName;
                if (ModelNameCustomized)
                {
                    Model.ForwardInstance.ModelName = EditModel.ModelName;
                }
                if (DescriptionCustomized)
                {
                    Model.ForwardInstance.Description = EditModel.Description;
                }
                if (TagsCustomized)
                {
                    Model.ForwardInstance.Tags = EditModel.Tags;
                }
            }
            EditModel.ResetModified(false);
            OnUpdated(this, null);

            // send update back to solution builder
            SendEditModelPerformed();

            // send update for any updated Enumerations
            if (EnumerationsFolder != null && EnumerationsFolder.IsEdited == true)
            {
                EnumerationsFolder.Update();
            }

            // send update for any updated ModelObjects
            if (ModelObjectsFolder != null && ModelObjectsFolder.IsEdited == true)
            {
                ModelObjectsFolder.Update();
            }
        }