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

            #region protected
            #endregion protected

            return(true);
        }
Example #2
0
        ///--------------------------------------------------------------------------------
        /// <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 PropertyRelationship();
                    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);
        }
Example #3
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method copies changed metadata between the input
        /// instance and the current instance.</summary>
        ///
        /// <param name="inputPropertyRelationship">The propertyrelationship to get metadata.</param>
        ///--------------------------------------------------------------------------------
        public void CopyChangedMetadata(PropertyRelationship inputPropertyRelationship)
        {
            PropertyID     = inputPropertyRelationship.PropertyID;
            RelationshipID = inputPropertyRelationship.RelationshipID;
            Order          = inputPropertyRelationship.Order;
            IsAutoUpdated  = inputPropertyRelationship.IsAutoUpdated;
            Description    = inputPropertyRelationship.Description;

            #region protected
            #endregion protected
        }
Example #4
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method deletes the current PropertyRelationship item from the solution.</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 ///--------------------------------------------------------------------------------
 public static void DeleteCurrentItemFromSolution(Solution solutionContext)
 {
     if (solutionContext.CurrentPropertyRelationship != null)
     {
         PropertyRelationship existingItem = solutionContext.PropertyRelationshipList.Find(i => i.PropertyRelationshipID == solutionContext.CurrentPropertyRelationship.PropertyRelationshipID);
         if (existingItem != null)
         {
             solutionContext.PropertyRelationshipList.Remove(solutionContext.CurrentPropertyRelationship);
         }
     }
 }
Example #5
0
        ///--------------------------------------------------------------------------------
        /// <summary>This property returns a copy of the forward engineering data for the solution.</summary>
        ///--------------------------------------------------------------------------------
        public new EntityReference GetForwardInstance(Solution forwardSolution)
        {
            bool            isCustomized = false;
            EntityReference forwardItem  = new EntityReference();

            if (ForwardInstance != null)
            {
                forwardItem.TransformDataFromObject(ForwardInstance, null, false);
                isCustomized = true;
            }
            else if (IsAutoUpdated == false)
            {
                forwardItem.TransformDataFromObject(this, null, false);
                isCustomized = true;
            }
            else
            {
                forwardItem.PropertyID = PropertyID;
            }
            foreach (PropertyRelationship item in PropertyRelationshipList)
            {
                item.PropertyBase = this;
                PropertyRelationship forwardChildItem = item.GetForwardInstance(forwardSolution);
                if (forwardChildItem != null)
                {
                    forwardItem.PropertyRelationshipList.Add(forwardChildItem);
                    isCustomized = true;
                }
            }
            if (isCustomized == false)
            {
                return(null);
            }
            forwardItem.SpecSourceName = DefaultSourceName;
            if (forwardSolution.ReferencedModelIDs.Find("ItemName", forwardItem.SpecSourceName) == null)
            {
                forwardSolution.ReferencedModelIDs.Add(CreateIDReference());
            }

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

            return(forwardItem);
        }
Example #6
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds a tag to TagList.</summary>
 ///--------------------------------------------------------------------------------
 public override void AddTag(string tagName)
 {
     if (ReverseInstance == null && IsAutoUpdated == true)
     {
         ReverseInstance = new PropertyRelationship();
         ReverseInstance.TransformDataFromObject(this, null, false);
         IsAutoUpdated = false;
     }
     base.AddTag(tagName);
     if (ForwardInstance == null)
     {
         ForwardInstance = new PropertyRelationship();
         ForwardInstance.PropertyRelationshipID = PropertyRelationshipID;
     }
     if (ForwardInstance.TagList.Find(t => t.TagName == tagName) == null)
     {
         ForwardInstance.TagList.Add(new Tag(Guid.NewGuid(), tagName));
     }
 }
Example #7
0
        ///--------------------------------------------------------------------------------
        /// <summary>This property returns a copy of the forward engineering data for the solution.</summary>
        ///--------------------------------------------------------------------------------
        public PropertyRelationship GetForwardInstance(Solution forwardSolution)
        {
            bool isCustomized = false;
            PropertyRelationship forwardItem = new PropertyRelationship();

            if (ForwardInstance != null)
            {
                forwardItem.TransformDataFromObject(ForwardInstance, null, false);
                isCustomized = true;
            }
            else if (IsAutoUpdated == false)
            {
                forwardItem.TransformDataFromObject(this, null, false);
                isCustomized = true;
            }
            else
            {
                forwardItem.PropertyRelationshipID = PropertyRelationshipID;
            }
            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);
        }
Example #8
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method adds this item to the parent, if not found.</summary>
        ///--------------------------------------------------------------------------------
        public void AddToParent()
        {
            PropertyBase propertyBase = Solution.PropertyBaseList.Find(i => i.PropertyID == PropertyID);

            if (propertyBase != null)
            {
                PropertyBase = propertyBase;
                SetID();                  // id (from saved ids) may change based on parent info
                PropertyRelationship propertyRelationship = propertyBase.PropertyRelationshipList.Find(i => i.PropertyRelationshipID == PropertyRelationshipID);
                if (propertyRelationship != null)
                {
                    if (propertyRelationship != this)
                    {
                        propertyBase.PropertyRelationshipList.Remove(propertyRelationship);
                        propertyBase.PropertyRelationshipList.Add(this);
                    }
                }
                else
                {
                    propertyBase.PropertyRelationshipList.Add(this);
                }
            }
        }
Example #9
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether the input instance metadata is
        /// effectively empty.</summary>
        ///
        /// <param name="inputPropertyRelationship">The propertyrelationship to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsEmptyMetadata(PropertyRelationship inputPropertyRelationship)
        {
            if (inputPropertyRelationship == null)
            {
                return(true);
            }
            if (inputPropertyRelationship.TagList.Count > 0)
            {
                return(false);
            }
            if (PropertyID != inputPropertyRelationship.PropertyID)
            {
                return(false);
            }
            if (RelationshipID != inputPropertyRelationship.RelationshipID)
            {
                return(false);
            }
            if (Order != DefaultValue.Int)
            {
                return(false);
            }
            if (IsAutoUpdated != inputPropertyRelationship.IsAutoUpdated)
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputPropertyRelationship.Description))
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }
Example #10
0
 ///--------------------------------------------------------------------------------
 /// <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.CurrentPropertyRelationship != null)
     {
         string validationErrors = solutionContext.CurrentPropertyRelationship.GetValidationErrors();
         if (!String.IsNullOrEmpty(validationErrors))
         {
             templateContext.LogException(solutionContext, solutionContext.CurrentPropertyRelationship, validationErrors, lineNumber, InterpreterTypeCode.Output);
         }
         // link item to known id, solution, and parent
         solutionContext.CurrentPropertyRelationship.Solution = solutionContext;
         solutionContext.CurrentPropertyRelationship.AddToParent();
         PropertyRelationship existingItem = solutionContext.PropertyRelationshipList.Find(i => i.PropertyRelationshipID == solutionContext.CurrentPropertyRelationship.PropertyRelationshipID);
         if (existingItem == null)
         {
             // add new item to solution
             solutionContext.CurrentPropertyRelationship.AssignProperty("PropertyRelationshipID", solutionContext.CurrentPropertyRelationship.PropertyRelationshipID);
             solutionContext.CurrentPropertyRelationship.ReverseInstance.ResetModified(false);
             solutionContext.PropertyRelationshipList.Add(solutionContext.CurrentPropertyRelationship);
         }
         else
         {
             // update existing item in solution
             if (existingItem.Solution == null)
             {
                 existingItem.Solution = solutionContext;
             }
             if (existingItem.ForwardInstance == null && existingItem.IsAutoUpdated == false)
             {
                 existingItem.ForwardInstance = new PropertyRelationship();
                 existingItem.ForwardInstance.TransformDataFromObject(existingItem, null, false);
             }
             existingItem.TransformDataFromObject(solutionContext.CurrentPropertyRelationship, null, false);
             existingItem.AddToParent();
             existingItem.AssignProperty("PropertyRelationshipID", existingItem.PropertyRelationshipID);
             existingItem.ReverseInstance.ResetModified(false);
             solutionContext.CurrentPropertyRelationship = existingItem;
         }
         #region protected
         PropertyReference parentProperty = solutionContext.PropertyReferenceList.FindByID(solutionContext.CurrentPropertyRelationship.PropertyID);
         if (parentProperty != null)
         {
             solutionContext.CurrentPropertyRelationship.PropertyBase = parentProperty;
             parentProperty.PropertyRelationshipList.Add(solutionContext.CurrentPropertyRelationship);
         }
         else
         {
             Collection parentProperty2 = solutionContext.CollectionList.FindByID(solutionContext.CurrentPropertyRelationship.PropertyID);
             if (parentProperty2 != null)
             {
                 solutionContext.CurrentPropertyRelationship.PropertyBase = parentProperty2;
                 parentProperty2.PropertyRelationshipList.Add(solutionContext.CurrentPropertyRelationship);
             }
             else
             {
                 EntityReference parentProperty3 = solutionContext.EntityReferenceList.FindByID(solutionContext.CurrentPropertyRelationship.PropertyID);
                 if (parentProperty3 != null)
                 {
                     solutionContext.CurrentPropertyRelationship.PropertyBase = parentProperty3;
                     parentProperty3.PropertyRelationshipList.Add(solutionContext.CurrentPropertyRelationship);
                 }
             }
         }
         #endregion protected
     }
 }