///--------------------------------------------------------------------------------
        /// <summary>This method copies changed metadata between the input
        /// instance and the current instance.</summary>
        ///
        /// <param name="inputStateTransition">The statetransition to get metadata.</param>
        ///--------------------------------------------------------------------------------
        public void CopyChangedMetadata(StateTransition inputStateTransition)
        {
            StateTransitionName = inputStateTransition.StateTransitionName;
            FromStateID         = inputStateTransition.FromStateID;
            ToStateID           = inputStateTransition.ToStateID;
            IsAutoUpdated       = inputStateTransition.IsAutoUpdated;
            Description         = inputStateTransition.Description;

            #region protected
            #endregion protected
        }
 ///--------------------------------------------------------------------------------
 /// <summary>This method deletes the current StateTransition item from the solution.</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 ///--------------------------------------------------------------------------------
 public static void DeleteCurrentItemFromSolution(Solution solutionContext)
 {
     if (solutionContext.CurrentStateTransition != null)
     {
         StateTransition existingItem = solutionContext.StateTransitionList.Find(i => i.StateTransitionID == solutionContext.CurrentStateTransition.StateTransitionID);
         if (existingItem != null)
         {
             solutionContext.StateTransitionList.Remove(solutionContext.CurrentStateTransition);
         }
     }
 }
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds a tag to TagList.</summary>
 ///--------------------------------------------------------------------------------
 public override void AddTag(string tagName)
 {
     if (ReverseInstance == null && IsAutoUpdated == true)
     {
         ReverseInstance = new StateTransition();
         ReverseInstance.TransformDataFromObject(this, null, false);
         IsAutoUpdated = false;
     }
     base.AddTag(tagName);
     if (ForwardInstance == null)
     {
         ForwardInstance = new StateTransition();
         ForwardInstance.StateTransitionID = StateTransitionID;
     }
     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.CurrentStateTransition != null)
     {
         string validationErrors = solutionContext.CurrentStateTransition.GetValidationErrors();
         if (!String.IsNullOrEmpty(validationErrors))
         {
             templateContext.LogException(solutionContext, solutionContext.CurrentStateTransition, validationErrors, lineNumber, InterpreterTypeCode.Output);
         }
         // link item to known id, solution, and parent
         solutionContext.CurrentStateTransition.Solution = solutionContext;
         solutionContext.CurrentStateTransition.AddToParent();
         StateTransition existingItem = solutionContext.StateTransitionList.Find(i => i.StateTransitionID == solutionContext.CurrentStateTransition.StateTransitionID);
         if (existingItem == null)
         {
             // add new item to solution
             solutionContext.CurrentStateTransition.AssignProperty("StateTransitionID", solutionContext.CurrentStateTransition.StateTransitionID);
             solutionContext.CurrentStateTransition.ReverseInstance.ResetModified(false);
             solutionContext.StateTransitionList.Add(solutionContext.CurrentStateTransition);
         }
         else
         {
             // update existing item in solution
             if (existingItem.Solution == null)
             {
                 existingItem.Solution = solutionContext;
             }
             if (existingItem.ForwardInstance == null && existingItem.IsAutoUpdated == false)
             {
                 existingItem.ForwardInstance = new StateTransition();
                 existingItem.ForwardInstance.TransformDataFromObject(existingItem, null, false);
             }
             existingItem.TransformDataFromObject(solutionContext.CurrentStateTransition, null, false);
             existingItem.AddToParent();
             existingItem.AssignProperty("StateTransitionID", existingItem.StateTransitionID);
             existingItem.ReverseInstance.ResetModified(false);
             solutionContext.CurrentStateTransition = existingItem;
         }
         #region protected
         #endregion protected
     }
 }
        ///--------------------------------------------------------------------------------
        /// <summary>This method adds this item to the parent, if not found.</summary>
        ///--------------------------------------------------------------------------------
        public void AddToParent()
        {
            State state = Solution.StateList.Find(i => i.StateID == ToStateID);

            if (state != null)
            {
                ToState = state;
                SetID();                  // id (from saved ids) may change based on parent info
                StateTransition stateTransition = state.ToStateTransitionList.Find(i => i.StateTransitionID == StateTransitionID);
                if (stateTransition != null)
                {
                    if (stateTransition != this)
                    {
                        state.ToStateTransitionList.Remove(stateTransition);
                        state.ToStateTransitionList.Add(this);
                    }
                }
                else
                {
                    state.ToStateTransitionList.Add(this);
                }
            }
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether the input instance metadata is
        /// effectively empty.</summary>
        ///
        /// <param name="inputStateTransition">The statetransition to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsEmptyMetadata(StateTransition inputStateTransition)
        {
            if (inputStateTransition == null)
            {
                return(true);
            }
            if (inputStateTransition.TagList.Count > 0)
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputStateTransition.StateTransitionName))
            {
                return(false);
            }
            if (FromStateID != inputStateTransition.FromStateID)
            {
                return(false);
            }
            if (ToStateID != inputStateTransition.ToStateID)
            {
                return(false);
            }
            if (IsAutoUpdated != inputStateTransition.IsAutoUpdated)
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputStateTransition.Description))
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }