예제 #1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This property returns a copy of the forward engineering data for the solution.</summary>
        ///--------------------------------------------------------------------------------
        public StateModel GetForwardInstance(Solution forwardSolution)
        {
            bool       isCustomized = false;
            StateModel forwardItem  = new StateModel();

            if (ForwardInstance != null)
            {
                forwardItem.TransformDataFromObject(ForwardInstance, null, false);
                isCustomized = true;
            }
            else if (IsAutoUpdated == false)
            {
                forwardItem.TransformDataFromObject(this, null, false);
                isCustomized = true;
            }
            else
            {
                forwardItem.StateModelID = StateModelID;
            }
            foreach (State item in StateList)
            {
                item.StateModel = this;
                State forwardChildItem = item.GetForwardInstance(forwardSolution);
                if (forwardChildItem != null)
                {
                    forwardItem.StateList.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);
        }
예제 #2
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds a tag to TagList.</summary>
 ///--------------------------------------------------------------------------------
 public override void AddTag(string tagName)
 {
     if (ReverseInstance == null && IsAutoUpdated == true)
     {
         ReverseInstance = new StateModel();
         ReverseInstance.TransformDataFromObject(this, null, false);
         IsAutoUpdated = false;
     }
     base.AddTag(tagName);
     if (ForwardInstance == null)
     {
         ForwardInstance = new StateModel();
         ForwardInstance.StateModelID = StateModelID;
     }
     if (ForwardInstance.TagList.Find(t => t.TagName == tagName) == null)
     {
         ForwardInstance.TagList.Add(new Tag(Guid.NewGuid(), tagName));
     }
 }
예제 #3
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.CurrentStateModel != null)
     {
         string validationErrors = solutionContext.CurrentStateModel.GetValidationErrors();
         if (!String.IsNullOrEmpty(validationErrors))
         {
             templateContext.LogException(solutionContext, solutionContext.CurrentStateModel, validationErrors, lineNumber, InterpreterTypeCode.Output);
         }
         // link item to known id, solution, and parent
         solutionContext.CurrentStateModel.Solution = solutionContext;
         solutionContext.CurrentStateModel.AddToParent();
         StateModel existingItem = solutionContext.StateModelList.Find(i => i.StateModelID == solutionContext.CurrentStateModel.StateModelID);
         if (existingItem == null)
         {
             // add new item to solution
             solutionContext.CurrentStateModel.AssignProperty("StateModelID", solutionContext.CurrentStateModel.StateModelID);
             solutionContext.CurrentStateModel.ReverseInstance.ResetModified(false);
             solutionContext.StateModelList.Add(solutionContext.CurrentStateModel);
         }
         else
         {
             // update existing item in solution
             if (existingItem.Solution == null)
             {
                 existingItem.Solution = solutionContext;
             }
             if (existingItem.ForwardInstance == null && existingItem.IsAutoUpdated == false)
             {
                 existingItem.ForwardInstance = new StateModel();
                 existingItem.ForwardInstance.TransformDataFromObject(existingItem, null, false);
             }
             existingItem.TransformDataFromObject(solutionContext.CurrentStateModel, null, false);
             existingItem.AddToParent();
             existingItem.AssignProperty("StateModelID", existingItem.StateModelID);
             existingItem.ReverseInstance.ResetModified(false);
             solutionContext.CurrentStateModel = existingItem;
         }
         #region protected
         #endregion protected
     }
 }
예제 #4
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method adds this item to the parent, if not found.</summary>
        ///--------------------------------------------------------------------------------
        public void AddToParent()
        {
            Entity entity = Solution.EntityList.Find(i => i.EntityID == EntityID);

            if (entity != null)
            {
                Entity = entity;
                SetID();                  // id (from saved ids) may change based on parent info
                StateModel stateModel = entity.StateModelList.Find(i => i.StateModelID == StateModelID);
                if (stateModel != null)
                {
                    if (stateModel != this)
                    {
                        entity.StateModelList.Remove(stateModel);
                        entity.StateModelList.Add(this);
                    }
                }
                else
                {
                    entity.StateModelList.Add(this);
                }
            }
        }
예제 #5
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether or not any metadata is
        /// different between the input instance and the current instance.</summary>
        ///
        /// <param name="inputStateModel">The statemodel to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsIdenticalMetadata(StateModel inputStateModel)
        {
            if (StateModelName.GetString() != inputStateModel.StateModelName.GetString())
            {
                return(false);
            }
            if (EntityID.GetGuid() != inputStateModel.EntityID.GetGuid())
            {
                return(false);
            }
            if (IsAutoUpdated.GetBool() != inputStateModel.IsAutoUpdated.GetBool())
            {
                return(false);
            }
            if (Description.GetString() != inputStateModel.Description.GetString())
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }