///-------------------------------------------------------------------------------- /// <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 StepTransition(); 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 StepTransition GetForwardInstance(Solution forwardSolution) { bool isCustomized = false; StepTransition forwardItem = new StepTransition(); if (ForwardInstance != null) { forwardItem.TransformDataFromObject(ForwardInstance, null, false); isCustomized = true; } else if (IsAutoUpdated == false) { forwardItem.TransformDataFromObject(this, null, false); isCustomized = true; } else { forwardItem.StepTransitionID = StepTransitionID; } 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="inputStepTransition">The steptransition to compare metadata.</param> ///-------------------------------------------------------------------------------- public bool IsIdenticalMetadata(StepTransition inputStepTransition) { if (StepTransitionName.GetString() != inputStepTransition.StepTransitionName.GetString()) { return(false); } if (FromStepID.GetGuid() != inputStepTransition.FromStepID.GetGuid()) { return(false); } if (ToStepID.GetGuid() != inputStepTransition.ToStepID.GetGuid()) { return(false); } if (IsAutoUpdated.GetBool() != inputStepTransition.IsAutoUpdated.GetBool()) { return(false); } if (Description.GetString() != inputStepTransition.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="inputStepTransition">The steptransition to get metadata.</param> ///-------------------------------------------------------------------------------- public void CopyChangedMetadata(StepTransition inputStepTransition) { StepTransitionName = inputStepTransition.StepTransitionName; FromStepID = inputStepTransition.FromStepID; ToStepID = inputStepTransition.ToStepID; IsAutoUpdated = inputStepTransition.IsAutoUpdated; Description = inputStepTransition.Description; #region protected #endregion protected }
///-------------------------------------------------------------------------------- /// <summary>This method deletes the current StepTransition item from the solution.</summary> /// /// <param name="solutionContext">The associated solution.</param> ///-------------------------------------------------------------------------------- public static void DeleteCurrentItemFromSolution(Solution solutionContext) { if (solutionContext.CurrentStepTransition != null) { StepTransition existingItem = solutionContext.StepTransitionList.Find(i => i.StepTransitionID == solutionContext.CurrentStepTransition.StepTransitionID); if (existingItem != null) { solutionContext.StepTransitionList.Remove(solutionContext.CurrentStepTransition); } } }
///-------------------------------------------------------------------------------- /// <summary>This method adds a tag to TagList.</summary> ///-------------------------------------------------------------------------------- public override void AddTag(string tagName) { if (ReverseInstance == null && IsAutoUpdated == true) { ReverseInstance = new StepTransition(); ReverseInstance.TransformDataFromObject(this, null, false); IsAutoUpdated = false; } base.AddTag(tagName); if (ForwardInstance == null) { ForwardInstance = new StepTransition(); ForwardInstance.StepTransitionID = StepTransitionID; } 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.CurrentStepTransition != null) { string validationErrors = solutionContext.CurrentStepTransition.GetValidationErrors(); if (!String.IsNullOrEmpty(validationErrors)) { templateContext.LogException(solutionContext, solutionContext.CurrentStepTransition, validationErrors, lineNumber, InterpreterTypeCode.Output); } // link item to known id, solution, and parent solutionContext.CurrentStepTransition.Solution = solutionContext; solutionContext.CurrentStepTransition.AddToParent(); StepTransition existingItem = solutionContext.StepTransitionList.Find(i => i.StepTransitionID == solutionContext.CurrentStepTransition.StepTransitionID); if (existingItem == null) { // add new item to solution solutionContext.CurrentStepTransition.AssignProperty("StepTransitionID", solutionContext.CurrentStepTransition.StepTransitionID); solutionContext.CurrentStepTransition.ReverseInstance.ResetModified(false); solutionContext.StepTransitionList.Add(solutionContext.CurrentStepTransition); } else { // update existing item in solution if (existingItem.Solution == null) { existingItem.Solution = solutionContext; } if (existingItem.ForwardInstance == null && existingItem.IsAutoUpdated == false) { existingItem.ForwardInstance = new StepTransition(); existingItem.ForwardInstance.TransformDataFromObject(existingItem, null, false); } existingItem.TransformDataFromObject(solutionContext.CurrentStepTransition, null, false); existingItem.AddToParent(); existingItem.AssignProperty("StepTransitionID", existingItem.StepTransitionID); existingItem.ReverseInstance.ResetModified(false); solutionContext.CurrentStepTransition = existingItem; } #region protected #endregion protected } }
///-------------------------------------------------------------------------------- /// <summary>This method adds this item to the parent, if not found.</summary> ///-------------------------------------------------------------------------------- public void AddToParent() { Step step = Solution.StepList.Find(i => i.StepID == ToStepID); if (step != null) { ToStep = step; SetID(); // id (from saved ids) may change based on parent info StepTransition stepTransition = step.ToStepTransitionList.Find(i => i.StepTransitionID == StepTransitionID); if (stepTransition != null) { if (stepTransition != this) { step.ToStepTransitionList.Remove(stepTransition); step.ToStepTransitionList.Add(this); } } else { step.ToStepTransitionList.Add(this); } } }
///-------------------------------------------------------------------------------- /// <summary>This method determines whether the input instance metadata is /// effectively empty.</summary> /// /// <param name="inputStepTransition">The steptransition to compare metadata.</param> ///-------------------------------------------------------------------------------- public bool IsEmptyMetadata(StepTransition inputStepTransition) { if (inputStepTransition == null) { return(true); } if (inputStepTransition.TagList.Count > 0) { return(false); } if (!String.IsNullOrEmpty(inputStepTransition.StepTransitionName)) { return(false); } if (FromStepID != inputStepTransition.FromStepID) { return(false); } if (ToStepID != inputStepTransition.ToStepID) { return(false); } if (IsAutoUpdated != inputStepTransition.IsAutoUpdated) { return(false); } if (!String.IsNullOrEmpty(inputStepTransition.Description)) { return(false); } #region protected #endregion protected return(true); }