Beispiel #1
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 override bool AssignProperty(string propertyName, object propertyValue)
        {
            if (this.SetPropertyValue(propertyName, propertyValue) == true)
            {
                if (ReverseInstance == null)
                {
                    ReverseInstance = new XmlSource();
                    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);
        }
Beispiel #2
0
        ///--------------------------------------------------------------------------------
        /// <summary>This property returns a copy of the forward engineering data for the solution.</summary>
        ///--------------------------------------------------------------------------------
        public new XmlSource GetForwardInstance(Solution forwardSolution)
        {
            bool      isCustomized = false;
            XmlSource forwardItem  = new XmlSource();

            if (ForwardInstance != null)
            {
                forwardItem.TransformDataFromObject(ForwardInstance, null, false);
                isCustomized = true;
            }
            else if (IsAutoUpdated == false)
            {
                forwardItem.TransformDataFromObject(this, null, false);
                isCustomized = true;
            }
            else
            {
                forwardItem.SpecificationSourceID = SpecificationSourceID;
            }
            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 returns a copy of the forward engineering data for the solution.</summary>
        ///--------------------------------------------------------------------------------
        public XmlSource GetForwardInstance()
        {
            XmlSource forwardItem = new XmlSource();

            forwardItem.TransformDataFromObject(this, null, false);
            return(forwardItem);
        }
Beispiel #4
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method copies changed metadata between the input
        /// instance and the current instance.</summary>
        ///
        /// <param name="inputXmlSource">The xmlsource to get metadata.</param>
        ///--------------------------------------------------------------------------------
        public void CopyChangedMetadata(XmlSource inputXmlSource)
        {
            SourceFileName = inputXmlSource.SourceFileName;
            SourceFilePath = inputXmlSource.SourceFilePath;

            #region protected
            #endregion protected
        }
Beispiel #5
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method deletes the current XmlSource item from the solution.</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 ///--------------------------------------------------------------------------------
 public static void DeleteCurrentItemFromSolution(Solution solutionContext)
 {
     if (solutionContext.CurrentXmlSource != null)
     {
         XmlSource existingItem = solutionContext.XmlSourceList.Find(i => i.SpecificationSourceID == solutionContext.CurrentXmlSource.SpecificationSourceID);
         if (existingItem != null)
         {
             solutionContext.XmlSourceList.Remove(solutionContext.CurrentXmlSource);
         }
     }
 }
Beispiel #6
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether or not any metadata is
        /// different between the input instance and the current instance.</summary>
        ///
        /// <param name="inputXmlSource">The xmlsource to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsIdenticalMetadata(XmlSource inputXmlSource)
        {
            if (SourceFileName.GetString() != inputXmlSource.SourceFileName.GetString())
            {
                return(false);
            }
            if (SourceFilePath.GetString() != inputXmlSource.SourceFilePath.GetString())
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }
Beispiel #7
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds a tag to TagList.</summary>
 ///--------------------------------------------------------------------------------
 public override void AddTag(string tagName)
 {
     if (ReverseInstance == null && IsAutoUpdated == true)
     {
         ReverseInstance = new XmlSource();
         ReverseInstance.TransformDataFromObject(this, null, false);
         IsAutoUpdated = false;
     }
     base.AddTag(tagName);
     if (ForwardInstance == null)
     {
         ForwardInstance = new XmlSource();
         ForwardInstance.SpecificationSourceID = SpecificationSourceID;
     }
     if (ForwardInstance.TagList.Find(t => t.TagName == tagName) == null)
     {
         ForwardInstance.TagList.Add(new Tag(Guid.NewGuid(), tagName));
     }
 }
Beispiel #8
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.CurrentXmlSource != null)
     {
         string validationErrors = solutionContext.CurrentXmlSource.GetValidationErrors();
         if (!String.IsNullOrEmpty(validationErrors))
         {
             templateContext.LogException(solutionContext, solutionContext.CurrentXmlSource, validationErrors, lineNumber, InterpreterTypeCode.Output);
         }
         // link item to known id, solution, and parent
         solutionContext.CurrentXmlSource.Solution = solutionContext;
         solutionContext.CurrentXmlSource.AddToParent();
         XmlSource existingItem = solutionContext.XmlSourceList.Find(i => i.SpecificationSourceID == solutionContext.CurrentXmlSource.SpecificationSourceID);
         if (existingItem == null)
         {
             // add new item to solution
             solutionContext.CurrentXmlSource.AssignProperty("SpecificationSourceID", solutionContext.CurrentXmlSource.SpecificationSourceID);
             solutionContext.CurrentXmlSource.ReverseInstance.ResetModified(false);
             solutionContext.XmlSourceList.Add(solutionContext.CurrentXmlSource);
         }
         else
         {
             // update existing item in solution
             if (existingItem.Solution == null)
             {
                 existingItem.Solution = solutionContext;
             }
             if (existingItem.ForwardInstance == null && existingItem.IsAutoUpdated == false)
             {
                 existingItem.ForwardInstance = new XmlSource();
                 existingItem.ForwardInstance.TransformDataFromObject(existingItem, null, false);
             }
             existingItem.TransformDataFromObject(solutionContext.CurrentXmlSource, null, false);
             existingItem.AddToParent();
             existingItem.AssignProperty("SpecificationSourceID", existingItem.SpecificationSourceID);
             existingItem.ReverseInstance.ResetModified(false);
             solutionContext.CurrentXmlSource = existingItem;
         }
         #region protected
         #endregion protected
     }
 }
Beispiel #9
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether the input instance metadata is
        /// effectively empty.</summary>
        ///
        /// <param name="inputXmlSource">The xmlsource to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsEmptyMetadata(XmlSource inputXmlSource)
        {
            if (inputXmlSource == null)
            {
                return(true);
            }
            if (inputXmlSource.TagList.Count > 0)
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputXmlSource.SourceFileName))
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputXmlSource.SourceFilePath))
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }