///--------------------------------------------------------------------------------
        /// <summary>This method assigns a value to a property, and updates corresponding
        /// forward and reverse engineering data.</summary>
        ///
        /// <param name="propertyName">The property name.</param>
        /// <param name="propertyValue">The property value.</param>
        ///--------------------------------------------------------------------------------
        public virtual bool AssignProperty(string propertyName, object propertyValue)
        {
            if (this.SetPropertyValue(propertyName, propertyValue) == true)
            {
                if (ReverseInstance == null)
                {
                    ReverseInstance = new StageTransition();
                    ReverseInstance.TransformDataFromObject(this, null, false);
                }
                else
                {
                    ReverseInstance.SetPropertyValue(propertyName, propertyValue);
                }
                if (ForwardInstance != null)
                {
                    this.TransformDataFromObject(ForwardInstance, null, false, true);
                }
            }
            else
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This property returns a copy of the forward engineering data for the solution.</summary>
        ///--------------------------------------------------------------------------------
        public StageTransition GetForwardInstance(Solution forwardSolution)
        {
            bool            isCustomized = false;
            StageTransition forwardItem  = new StageTransition();

            if (ForwardInstance != null)
            {
                forwardItem.TransformDataFromObject(ForwardInstance, null, false);
                isCustomized = true;
            }
            else if (IsAutoUpdated == false)
            {
                forwardItem.TransformDataFromObject(this, null, false);
                isCustomized = true;
            }
            else
            {
                forwardItem.StageTransitionID = StageTransitionID;
            }
            if (isCustomized == false)
            {
                return(null);
            }
            forwardItem.SpecSourceName = DefaultSourceName;
            if (forwardSolution.ReferencedModelIDs.Find("ItemName", forwardItem.SpecSourceName) == null)
            {
                forwardSolution.ReferencedModelIDs.Add(CreateIDReference());
            }

            #region protected
            #endregion protected

            return(forwardItem);
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether or not any metadata is
        /// different between the input instance and the current instance.</summary>
        ///
        /// <param name="inputStageTransition">The stagetransition to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsIdenticalMetadata(StageTransition inputStageTransition)
        {
            if (StageTransitionName.GetString() != inputStageTransition.StageTransitionName.GetString())
            {
                return(false);
            }
            if (FromStageID.GetGuid() != inputStageTransition.FromStageID.GetGuid())
            {
                return(false);
            }
            if (ToStageID.GetGuid() != inputStageTransition.ToStageID.GetGuid())
            {
                return(false);
            }
            if (IsAutoUpdated.GetBool() != inputStageTransition.IsAutoUpdated.GetBool())
            {
                return(false);
            }
            if (Description.GetString() != inputStageTransition.Description.GetString())
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method copies changed metadata between the input
        /// instance and the current instance.</summary>
        ///
        /// <param name="inputStageTransition">The stagetransition to get metadata.</param>
        ///--------------------------------------------------------------------------------
        public void CopyChangedMetadata(StageTransition inputStageTransition)
        {
            StageTransitionName = inputStageTransition.StageTransitionName;
            FromStageID         = inputStageTransition.FromStageID;
            ToStageID           = inputStageTransition.ToStageID;
            IsAutoUpdated       = inputStageTransition.IsAutoUpdated;
            Description         = inputStageTransition.Description;

            #region protected
            #endregion protected
        }
 ///--------------------------------------------------------------------------------
 /// <summary>This method deletes the current StageTransition item from the solution.</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 ///--------------------------------------------------------------------------------
 public static void DeleteCurrentItemFromSolution(Solution solutionContext)
 {
     if (solutionContext.CurrentStageTransition != null)
     {
         StageTransition existingItem = solutionContext.StageTransitionList.Find(i => i.StageTransitionID == solutionContext.CurrentStageTransition.StageTransitionID);
         if (existingItem != null)
         {
             solutionContext.StageTransitionList.Remove(solutionContext.CurrentStageTransition);
         }
     }
 }
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds a tag to TagList.</summary>
 ///--------------------------------------------------------------------------------
 public override void AddTag(string tagName)
 {
     if (ReverseInstance == null && IsAutoUpdated == true)
     {
         ReverseInstance = new StageTransition();
         ReverseInstance.TransformDataFromObject(this, null, false);
         IsAutoUpdated = false;
     }
     base.AddTag(tagName);
     if (ForwardInstance == null)
     {
         ForwardInstance = new StageTransition();
         ForwardInstance.StageTransitionID = StageTransitionID;
     }
     if (ForwardInstance.TagList.Find(t => t.TagName == tagName) == null)
     {
         ForwardInstance.TagList.Add(new Tag(Guid.NewGuid(), tagName));
     }
 }
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds the current item to the solution, if it is valid
 /// and not already present in the solution.</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="lineNumber">The line number of the associated statement.</param>
 ///--------------------------------------------------------------------------------
 public static void AddCurrentItemToSolution(Solution solutionContext, ITemplate templateContext, int lineNumber)
 {
     if (solutionContext.CurrentStageTransition != null)
     {
         string validationErrors = solutionContext.CurrentStageTransition.GetValidationErrors();
         if (!String.IsNullOrEmpty(validationErrors))
         {
             templateContext.LogException(solutionContext, solutionContext.CurrentStageTransition, validationErrors, lineNumber, InterpreterTypeCode.Output);
         }
         // link item to known id, solution, and parent
         solutionContext.CurrentStageTransition.Solution = solutionContext;
         solutionContext.CurrentStageTransition.AddToParent();
         StageTransition existingItem = solutionContext.StageTransitionList.Find(i => i.StageTransitionID == solutionContext.CurrentStageTransition.StageTransitionID);
         if (existingItem == null)
         {
             // add new item to solution
             solutionContext.CurrentStageTransition.AssignProperty("StageTransitionID", solutionContext.CurrentStageTransition.StageTransitionID);
             solutionContext.CurrentStageTransition.ReverseInstance.ResetModified(false);
             solutionContext.StageTransitionList.Add(solutionContext.CurrentStageTransition);
         }
         else
         {
             // update existing item in solution
             if (existingItem.Solution == null)
             {
                 existingItem.Solution = solutionContext;
             }
             if (existingItem.ForwardInstance == null && existingItem.IsAutoUpdated == false)
             {
                 existingItem.ForwardInstance = new StageTransition();
                 existingItem.ForwardInstance.TransformDataFromObject(existingItem, null, false);
             }
             existingItem.TransformDataFromObject(solutionContext.CurrentStageTransition, null, false);
             existingItem.AddToParent();
             existingItem.AssignProperty("StageTransitionID", existingItem.StageTransitionID);
             existingItem.ReverseInstance.ResetModified(false);
             solutionContext.CurrentStageTransition = existingItem;
         }
         #region protected
         #endregion protected
     }
 }
        ///--------------------------------------------------------------------------------
        /// <summary>This method adds this item to the parent, if not found.</summary>
        ///--------------------------------------------------------------------------------
        public void AddToParent()
        {
            Stage stage = Solution.StageList.Find(i => i.StageID == ToStageID);

            if (stage != null)
            {
                ToStage = stage;
                SetID();                  // id (from saved ids) may change based on parent info
                StageTransition stageTransition = stage.ToStageTransitionList.Find(i => i.StageTransitionID == StageTransitionID);
                if (stageTransition != null)
                {
                    if (stageTransition != this)
                    {
                        stage.ToStageTransitionList.Remove(stageTransition);
                        stage.ToStageTransitionList.Add(this);
                    }
                }
                else
                {
                    stage.ToStageTransitionList.Add(this);
                }
            }
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether the input instance metadata is
        /// effectively empty.</summary>
        ///
        /// <param name="inputStageTransition">The stagetransition to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsEmptyMetadata(StageTransition inputStageTransition)
        {
            if (inputStageTransition == null)
            {
                return(true);
            }
            if (inputStageTransition.TagList.Count > 0)
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputStageTransition.StageTransitionName))
            {
                return(false);
            }
            if (FromStageID != inputStageTransition.FromStageID)
            {
                return(false);
            }
            if (ToStageID != inputStageTransition.ToStageID)
            {
                return(false);
            }
            if (IsAutoUpdated != inputStageTransition.IsAutoUpdated)
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputStageTransition.Description))
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }