///-------------------------------------------------------------------------------- /// <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 PropertyBase(); 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 PropertyBase GetForwardInstance(Solution forwardSolution) { bool isCustomized = false; PropertyBase forwardItem = new PropertyBase(); 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 #endregion protected return(forwardItem); }
///-------------------------------------------------------------------------------- /// <summary>This method adds a tag to TagList.</summary> ///-------------------------------------------------------------------------------- public override void AddTag(string tagName) { if (ReverseInstance == null && IsAutoUpdated == true) { ReverseInstance = new PropertyBase(); ReverseInstance.TransformDataFromObject(this, null, false); IsAutoUpdated = false; } base.AddTag(tagName); if (ForwardInstance == null) { ForwardInstance = new PropertyBase(); ForwardInstance.PropertyID = PropertyID; } if (ForwardInstance.TagList.Find(t => t.TagName == tagName) == null) { ForwardInstance.TagList.Add(new Tag(Guid.NewGuid(), tagName)); } }