///--------------------------------------------------------------------------------
        /// <summary>This method determines whether or not any metadata is
        /// different between the input instance and the current instance.</summary>
        ///
        /// <param name="inputMethodRelationship">The methodrelationship to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsIdenticalMetadata(MethodRelationship inputMethodRelationship)
        {
            if (MethodID.GetGuid() != inputMethodRelationship.MethodID.GetGuid())
            {
                return(false);
            }
            if (RelationshipID.GetGuid() != inputMethodRelationship.RelationshipID.GetGuid())
            {
                return(false);
            }
            if (Order.GetInt() != inputMethodRelationship.Order.GetInt())
            {
                return(false);
            }
            if (IsAutoUpdated.GetBool() != inputMethodRelationship.IsAutoUpdated.GetBool())
            {
                return(false);
            }
            if (Description.GetString() != inputMethodRelationship.Description.GetString())
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }
        ///--------------------------------------------------------------------------------
        /// <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 MethodRelationship();
                    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 method copies changed metadata between the input
        /// instance and the current instance.</summary>
        ///
        /// <param name="inputMethodRelationship">The methodrelationship to get metadata.</param>
        ///--------------------------------------------------------------------------------
        public void CopyChangedMetadata(MethodRelationship inputMethodRelationship)
        {
            MethodID       = inputMethodRelationship.MethodID;
            RelationshipID = inputMethodRelationship.RelationshipID;
            Order          = inputMethodRelationship.Order;
            IsAutoUpdated  = inputMethodRelationship.IsAutoUpdated;
            Description    = inputMethodRelationship.Description;

            #region protected
            #endregion protected
        }
 ///--------------------------------------------------------------------------------
 /// <summary>This method deletes the current MethodRelationship item from the solution.</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 ///--------------------------------------------------------------------------------
 public static void DeleteCurrentItemFromSolution(Solution solutionContext)
 {
     if (solutionContext.CurrentMethodRelationship != null)
     {
         MethodRelationship existingItem = solutionContext.MethodRelationshipList.Find(i => i.MethodRelationshipID == solutionContext.CurrentMethodRelationship.MethodRelationshipID);
         if (existingItem != null)
         {
             solutionContext.MethodRelationshipList.Remove(solutionContext.CurrentMethodRelationship);
         }
     }
 }
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds a tag to TagList.</summary>
 ///--------------------------------------------------------------------------------
 public override void AddTag(string tagName)
 {
     if (ReverseInstance == null && IsAutoUpdated == true)
     {
         ReverseInstance = new MethodRelationship();
         ReverseInstance.TransformDataFromObject(this, null, false);
         IsAutoUpdated = false;
     }
     base.AddTag(tagName);
     if (ForwardInstance == null)
     {
         ForwardInstance = new MethodRelationship();
         ForwardInstance.MethodRelationshipID = MethodRelationshipID;
     }
     if (ForwardInstance.TagList.Find(t => t.TagName == tagName) == null)
     {
         ForwardInstance.TagList.Add(new Tag(Guid.NewGuid(), tagName));
     }
 }
        ///--------------------------------------------------------------------------------
        /// <summary>This property returns a copy of the forward engineering data for the solution.</summary>
        ///--------------------------------------------------------------------------------
        public MethodRelationship GetForwardInstance(Solution forwardSolution)
        {
            bool isCustomized = false;
            MethodRelationship forwardItem = new MethodRelationship();

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

            #region protected
            if (forwardItem.RelationshipID != Guid.Empty)
            {
                forwardItem.Relationship = Solution.RelationshipList.FindByID(forwardItem.RelationshipID);
                if (forwardItem.Relationship != null && forwardSolution.ReferencedModelIDs.Find("ItemName", forwardItem.Relationship.DefaultSourceName) == null)
                {
                    forwardSolution.ReferencedModelIDs.Add(forwardItem.Relationship.CreateIDReference());
                }
            }
            #endregion protected

            return(forwardItem);
        }
 ///--------------------------------------------------------------------------------
 /// <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.CurrentMethodRelationship != null)
     {
         string validationErrors = solutionContext.CurrentMethodRelationship.GetValidationErrors();
         if (!String.IsNullOrEmpty(validationErrors))
         {
             templateContext.LogException(solutionContext, solutionContext.CurrentMethodRelationship, validationErrors, lineNumber, InterpreterTypeCode.Output);
         }
         // link item to known id, solution, and parent
         solutionContext.CurrentMethodRelationship.Solution = solutionContext;
         solutionContext.CurrentMethodRelationship.AddToParent();
         MethodRelationship existingItem = solutionContext.MethodRelationshipList.Find(i => i.MethodRelationshipID == solutionContext.CurrentMethodRelationship.MethodRelationshipID);
         if (existingItem == null)
         {
             // add new item to solution
             solutionContext.CurrentMethodRelationship.AssignProperty("MethodRelationshipID", solutionContext.CurrentMethodRelationship.MethodRelationshipID);
             solutionContext.CurrentMethodRelationship.ReverseInstance.ResetModified(false);
             solutionContext.MethodRelationshipList.Add(solutionContext.CurrentMethodRelationship);
         }
         else
         {
             // update existing item in solution
             if (existingItem.Solution == null)
             {
                 existingItem.Solution = solutionContext;
             }
             if (existingItem.ForwardInstance == null && existingItem.IsAutoUpdated == false)
             {
                 existingItem.ForwardInstance = new MethodRelationship();
                 existingItem.ForwardInstance.TransformDataFromObject(existingItem, null, false);
             }
             existingItem.TransformDataFromObject(solutionContext.CurrentMethodRelationship, null, false);
             existingItem.AddToParent();
             existingItem.AssignProperty("MethodRelationshipID", existingItem.MethodRelationshipID);
             existingItem.ReverseInstance.ResetModified(false);
             solutionContext.CurrentMethodRelationship = existingItem;
         }
         #region protected
         #endregion protected
     }
 }
        ///--------------------------------------------------------------------------------
        /// <summary>This method adds this item to the parent, if not found.</summary>
        ///--------------------------------------------------------------------------------
        public void AddToParent()
        {
            Method method = Solution.MethodList.Find(i => i.MethodID == MethodID);

            if (method != null)
            {
                Method = method;
                SetID();                  // id (from saved ids) may change based on parent info
                MethodRelationship methodRelationship = method.MethodRelationshipList.Find(i => i.MethodRelationshipID == MethodRelationshipID);
                if (methodRelationship != null)
                {
                    if (methodRelationship != this)
                    {
                        method.MethodRelationshipList.Remove(methodRelationship);
                        method.MethodRelationshipList.Add(this);
                    }
                }
                else
                {
                    method.MethodRelationshipList.Add(this);
                }
            }
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether the input instance metadata is
        /// effectively empty.</summary>
        ///
        /// <param name="inputMethodRelationship">The methodrelationship to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsEmptyMetadata(MethodRelationship inputMethodRelationship)
        {
            if (inputMethodRelationship == null)
            {
                return(true);
            }
            if (inputMethodRelationship.TagList.Count > 0)
            {
                return(false);
            }
            if (MethodID != inputMethodRelationship.MethodID)
            {
                return(false);
            }
            if (RelationshipID != inputMethodRelationship.RelationshipID)
            {
                return(false);
            }
            if (Order != DefaultValue.Int)
            {
                return(false);
            }
            if (IsAutoUpdated != inputMethodRelationship.IsAutoUpdated)
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputMethodRelationship.Description))
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }