示例#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 AuditProperty();
                    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);
        }
示例#2
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method deletes the current AuditProperty item from the solution.</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 ///--------------------------------------------------------------------------------
 public static void DeleteCurrentItemFromSolution(Solution solutionContext)
 {
     if (solutionContext.CurrentAuditProperty != null)
     {
         AuditProperty existingItem = solutionContext.AuditPropertyList.Find(i => i.PropertyID == solutionContext.CurrentAuditProperty.PropertyID);
         if (existingItem != null)
         {
             solutionContext.AuditPropertyList.Remove(solutionContext.CurrentAuditProperty);
         }
     }
 }
示例#3
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method copies changed metadata between the input
        /// instance and the current instance.</summary>
        ///
        /// <param name="inputAuditProperty">The auditproperty to get metadata.</param>
        ///--------------------------------------------------------------------------------
        public void CopyChangedMetadata(AuditProperty inputAuditProperty)
        {
            PropertyName          = inputAuditProperty.PropertyName;
            IsAddAuditProperty    = inputAuditProperty.IsAddAuditProperty;
            IsUpdateAuditProperty = inputAuditProperty.IsUpdateAuditProperty;
            IsValueGenerated      = inputAuditProperty.IsValueGenerated;
            DataTypeCode          = inputAuditProperty.DataTypeCode;
            Precision             = inputAuditProperty.Precision;
            Scale        = inputAuditProperty.Scale;
            InitialValue = inputAuditProperty.InitialValue;

            #region protected
            #endregion protected
        }
示例#4
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether the input instance metadata is
        /// effectively empty.</summary>
        ///
        /// <param name="inputAuditProperty">The auditproperty to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsEmptyMetadata(AuditProperty inputAuditProperty)
        {
            if (inputAuditProperty == null)
            {
                return(true);
            }
            if (inputAuditProperty.TagList.Count > 0)
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputAuditProperty.PropertyName))
            {
                return(false);
            }
            if (IsAddAuditProperty != inputAuditProperty.IsAddAuditProperty)
            {
                return(false);
            }
            if (IsUpdateAuditProperty != inputAuditProperty.IsUpdateAuditProperty)
            {
                return(false);
            }
            if (IsValueGenerated != inputAuditProperty.IsValueGenerated)
            {
                return(false);
            }
            if (DataTypeCode != DefaultValue.Int)
            {
                return(false);
            }
            if (Precision != DefaultValue.Int)
            {
                return(false);
            }
            if (Scale != DefaultValue.Int)
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputAuditProperty.InitialValue))
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }
示例#5
0
        ///--------------------------------------------------------------------------------
        /// <summary>This property returns a copy of the forward engineering data for the solution.</summary>
        ///--------------------------------------------------------------------------------
        public new AuditProperty GetForwardInstance(Solution forwardSolution)
        {
            bool          isCustomized = false;
            AuditProperty forwardItem  = new AuditProperty();

            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);
        }
示例#6
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds a tag to TagList.</summary>
 ///--------------------------------------------------------------------------------
 public override void AddTag(string tagName)
 {
     if (ReverseInstance == null && IsAutoUpdated == true)
     {
         ReverseInstance = new AuditProperty();
         ReverseInstance.TransformDataFromObject(this, null, false);
         IsAutoUpdated = false;
     }
     base.AddTag(tagName);
     if (ForwardInstance == null)
     {
         ForwardInstance            = new AuditProperty();
         ForwardInstance.PropertyID = PropertyID;
     }
     if (ForwardInstance.TagList.Find(t => t.TagName == tagName) == null)
     {
         ForwardInstance.TagList.Add(new Tag(Guid.NewGuid(), tagName));
     }
 }
示例#7
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.CurrentAuditProperty != null)
     {
         string validationErrors = solutionContext.CurrentAuditProperty.GetValidationErrors();
         if (!String.IsNullOrEmpty(validationErrors))
         {
             templateContext.LogException(solutionContext, solutionContext.CurrentAuditProperty, validationErrors, lineNumber, InterpreterTypeCode.Output);
         }
         // link item to known id, solution, and parent
         solutionContext.CurrentAuditProperty.Solution = solutionContext;
         solutionContext.CurrentAuditProperty.AddToParent();
         AuditProperty existingItem = solutionContext.AuditPropertyList.Find(i => i.PropertyID == solutionContext.CurrentAuditProperty.PropertyID);
         if (existingItem == null)
         {
             // add new item to solution
             solutionContext.CurrentAuditProperty.AssignProperty("PropertyID", solutionContext.CurrentAuditProperty.PropertyID);
             solutionContext.CurrentAuditProperty.ReverseInstance.ResetModified(false);
             solutionContext.AuditPropertyList.Add(solutionContext.CurrentAuditProperty);
         }
         else
         {
             // update existing item in solution
             if (existingItem.Solution == null)
             {
                 existingItem.Solution = solutionContext;
             }
             if (existingItem.ForwardInstance == null && existingItem.IsAutoUpdated == false)
             {
                 existingItem.ForwardInstance = new AuditProperty();
                 existingItem.ForwardInstance.TransformDataFromObject(existingItem, null, false);
             }
             existingItem.TransformDataFromObject(solutionContext.CurrentAuditProperty, null, false);
             existingItem.AddToParent();
             existingItem.AssignProperty("PropertyID", existingItem.PropertyID);
             existingItem.ReverseInstance.ResetModified(false);
             solutionContext.CurrentAuditProperty = existingItem;
         }
         #region protected
         #endregion protected
     }
 }
示例#8
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether or not any metadata is
        /// different between the input instance and the current instance.</summary>
        ///
        /// <param name="inputAuditProperty">The auditproperty to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsIdenticalMetadata(AuditProperty inputAuditProperty)
        {
            if (PropertyName.GetString() != inputAuditProperty.PropertyName.GetString())
            {
                return(false);
            }
            if (IsAddAuditProperty.GetBool() != inputAuditProperty.IsAddAuditProperty.GetBool())
            {
                return(false);
            }
            if (IsUpdateAuditProperty.GetBool() != inputAuditProperty.IsUpdateAuditProperty.GetBool())
            {
                return(false);
            }
            if (IsValueGenerated.GetBool() != inputAuditProperty.IsValueGenerated.GetBool())
            {
                return(false);
            }
            if (DataTypeCode.GetInt() != inputAuditProperty.DataTypeCode.GetInt())
            {
                return(false);
            }
            if (Precision.GetInt() != inputAuditProperty.Precision.GetInt())
            {
                return(false);
            }
            if (Scale.GetInt() != inputAuditProperty.Scale.GetInt())
            {
                return(false);
            }
            if (InitialValue.GetString() != inputAuditProperty.InitialValue.GetString())
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }