Exemplo n.º 1
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method gets the updated content for the template.</summary>
 ///
 /// <param name="parentModelContext">The parent model context from which to generate code.</param>
 ///
 /// <returns>A string representing the generated code for the template.</returns>
 ///--------------------------------------------------------------------------------
 public string GetContent(IDomainEnterpriseObject parentModelContext)
 {
     try
     {
         ContentCodeBuilder.Clear();
         if (IsWatchTemplate == false)
         {
             // clear parameters and variables if not passed in for temporary watch templates
             Parameters.Clear();
             Variables.Clear();
         }
         if (ContentAST == null && TemplateContent != String.Empty)
         {
             ParseContent(Solution.IsSampleMode);
         }
         if (ContentAST != null && ContentAST.ChildNodes.Count > 0)
         {
             ContentAST.InterpretNode(InterpreterTypeCode.Content, Solution, this, GetTemplateModelContext(parentModelContext), null);
         }
         ContentCode = ContentCodeBuilder.ToString() + MessageBuilder.ToString();
         return(ContentCode);
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         HasErrors = true;
         Solution.ShowIssue(ex.Message + ex.StackTrace, DisplayValues.Exception_CodeGenerationTitle, Solution.IsSampleMode);
     }
     return(null);
 }
Exemplo n.º 2
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the collection context associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        ///--------------------------------------------------------------------------------
        public IEnterpriseEnumerable GetCollection(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, ModelContextNode collectionType, InterpreterTypeCode interpreterType)
        {
            IDomainEnterpriseObject collectionContext = modelContext;

            if (ModelContext != null)
            {
                bool isValidContext;
                collectionContext = ModelContext.GetModelContext(solutionContext, templateContext, modelContext, out isValidContext);
                return(collectionType.GetCollection(solutionContext, templateContext, collectionContext));
            }
            else if (CurrentItem != null)
            {
                collectionContext = CurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
                return(collectionType.GetCollection(solutionContext, templateContext, collectionContext));
            }
            else if (SpecCurrentItem != null)
            {
                collectionContext = SpecCurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
                return(collectionType.GetCollection(solutionContext, templateContext, collectionContext));
            }
            else if (CollectionHelper != null)
            {
                return(CollectionHelper.GetCollection(solutionContext, templateContext, modelContext, collectionType, interpreterType));
            }
            return(null);
        }
Exemplo n.º 3
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the model context associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="helperModelContext">The associated helper model context node.</param>
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        ///--------------------------------------------------------------------------------
        public IDomainEnterpriseObject GetModelContext(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, ModelContextNode helperModelContext, InterpreterTypeCode interpreterType)
        {
            IDomainEnterpriseObject parentContext = modelContext;

            if (ModelContext != null)
            {
                bool isValidContext;
                parentContext = ModelContext.GetModelContext(solutionContext, templateContext, modelContext, out isValidContext);
            }
            else if (CurrentItem != null)
            {
                parentContext = CurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
            }
            if (MethodName == LanguageTerms.FindMethod)
            {
                IEnterpriseEnumerable collection = helperModelContext.GetCollection(solutionContext, templateContext, parentContext);
                if (collection != null)
                {
                    if (ModelProperty != null)
                    {
                        object paramValue            = Parameter.GetObjectValue(solutionContext, templateContext, modelContext, interpreterType);
                        IDomainEnterpriseObject item = collection.FindItem(ModelProperty.ModelPropertyName, paramValue) as IDomainEnterpriseObject;
                        if (item != null)
                        {
                            return(item);
                        }
                        if (modelContext is ObjectInstance)
                        {
                            // get item by specified model property
                            foreach (ObjectInstance instance in collection)
                            {
                                foreach (PropertyInstance property in instance.PropertyInstanceList)
                                {
                                    if (property.ModelPropertyName == ModelProperty.ModelPropertyName && property.PropertyValue == paramValue.ToString())
                                    {
                                        return(instance);
                                    }
                                }
                            }
                        }
                        return(null);
                    }
                    else
                    {
                        string parameterValue = Parameter.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
                        Guid   parameterID    = Guid.Empty;
                        if (Guid.TryParse(parameterValue, out parameterID))
                        {
                            return(collection.FindItemByID(parameterID) as IDomainEnterpriseObject);
                        }
                        else
                        {
                            LogException(solutionContext, templateContext, modelContext, DisplayValues.Message_InterpreterBadFindParameter, interpreterType);
                        }
                    }
                }
                return(null);
            }
            return(modelContext);
        }
Exemplo n.º 4
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method generates the associated output path for the template.</summary>
 ///
 /// <param name="parentModelContext">The parent model context from which to generate code.</param>
 ///
 /// <returns>A string representing the generated code for the template.</returns>
 ///--------------------------------------------------------------------------------
 public string GenerateOutput(IDomainEnterpriseObject parentModelContext)
 {
     try
     {
         MessageBuilder.Clear();
         OutputCodeBuilder.Clear();
         Parameters.Clear();
         Variables.Clear();
         if (OutputAST == null)
         {
             ParseOutput(Solution.IsSampleMode);
         }
         IDomainEnterpriseObject context = GetTemplateModelContext(parentModelContext);
         if (OutputAST != null && OutputAST.ChildNodes.Count > 0)
         {
             OutputAST.InterpretNode(InterpreterTypeCode.Output, Solution, this, context, null);
             OutputCode = OutputCodeBuilder.ToString() + MessageBuilder.ToString();
         }
         return(OutputCode);
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         HasErrors = true;
         Solution.ShowIssue(ex.Message + ex.StackTrace, DisplayValues.Exception_CodeGenerationTitle, Solution.IsSampleMode);
     }
     return(null);
 }
Exemplo n.º 5
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the collection context associated with this item.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="objectName">The name of the model object type.</param>
        /// <param name="modelContext">The associated model context.</param>
        ///--------------------------------------------------------------------------------
        public static IEnterpriseEnumerable GetCollectionContext(Solution solutionContext, string objectName, IDomainEnterpriseObject modelContext)
        {
            IDomainEnterpriseObject nodeContext = modelContext;

            while (nodeContext != null)
            {
                if (nodeContext is ObjectInstance)
                {
                    ObjectInstance modelObjectContext = modelContext as ObjectInstance;
                    if (solutionContext.ObjectInstanceList.Find(i => i.ModelObjectName == objectName && i.ParentObjectInstanceID == modelObjectContext.ObjectInstanceID) != null)
                    {
                        return(new EnterpriseDataObjectList <ObjectInstance>(solutionContext.ObjectInstanceList.FindAll(i => i.ModelObjectName == objectName && i.ParentObjectInstanceID == modelObjectContext.ObjectInstanceID), false));
                    }
                }
                if (nodeContext is ModelObject)
                {
                    if ((nodeContext as ModelObject).ModelObjectName == objectName)
                    {
                        return((nodeContext as ModelObject).ObjectInstanceList);
                    }
                    else
                    {
                        return(new EnterpriseDataObjectList <ObjectInstance>());
                    }
                }
                if (nodeContext is Solution)
                {
                    return(new EnterpriseDataObjectList <ObjectInstance>(solutionContext.ObjectInstanceList.FindAll(i => i.ModelObjectName == objectName), false));
                }
                nodeContext = nodeContext.GetParentItem();
            }
            return(null);
        }
Exemplo n.º 6
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method updates the output watch expressions.</summary>
 ///
 /// <param name="parentModelContext">The parent model context from which to generate code.</param>
 ///--------------------------------------------------------------------------------
 public void UpdateOutputWatches(IDomainEnterpriseObject parentModelContext)
 {
     foreach (DebugItem item in OutputDebugItems)
     {
         item.DebugValue = GetWatchContent(item.DebugExpression, parentModelContext);
     }
 }
Exemplo n.º 7
0
        ///--------------------------------------------------------------------------------
        /// <summary>Interpret this node to produce code, output, or model data..</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        ///--------------------------------------------------------------------------------
        public object GetPropertyObjectValue(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
        {
            IDomainEnterpriseObject nodeContext = GetModelContext(solutionContext, templateContext, modelContext);

            if (nodeContext != null)
            {
                return(nodeContext.ID);
            }
            return(null);
        }
Exemplo n.º 8
0
        ///--------------------------------------------------------------------------------
        /// <summary>Interpret this node to produce code, output, or model data..</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        ///--------------------------------------------------------------------------------
        public string GetPropertyStringValue(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
        {
            IDomainEnterpriseObject nodeContext = GetModelContext(solutionContext, templateContext, modelContext);

            if (nodeContext != null)
            {
                return(nodeContext.ID.ToString());
            }
            return("null");
        }
Exemplo n.º 9
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method adds an item to the list of items to tag.</summary>
        ///
        /// <param name="itemID">The ID of the item.</param>
        /// <param name="itemName">The name of the item.</param>
        /// <param name="item">The item.</param>
        ///--------------------------------------------------------------------------------
        public void AddItemToTag(Guid itemID, string itemName, IDomainEnterpriseObject item)
        {
            WorkspaceViewModel view = new WorkspaceViewModel(itemID, itemName);

            view.Item = item;
            if (ItemHasTag(SelectedTag, itemID) == true)
            {
                view.IsSelected = true;
                ItemsTagged[itemID.ToString()] = true;
            }
            ItemsToTag.Add(view);
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the current model context for the item.</summary>
        ///
        /// <param name="parentModelContext">The parent model context from which to get current model context.</param>
        /// <param name="isValidContext">Output flag, signifying whether context returned is a valid one.</param>
        ///--------------------------------------------------------------------------------
        public static IDomainEnterpriseObject GetModelContext(Solution solutionContext, IDomainEnterpriseObject parentModelContext, out bool isValidContext)
        {
            isValidContext = true;
            IDomainEnterpriseObject modelContext = parentModelContext;

            while (modelContext != null)
            {
                if (modelContext is SqlViewProperty)
                {
                    return(modelContext);
                }
                else if (solutionContext.IsSampleMode == true && solutionContext.NeedsSample == true && modelContext is SqlView)
                {
                    solutionContext.NeedsSample = false;
                    SqlView parent = modelContext as SqlView;
                    if (parent.SqlViewPropertyList.Count > 0)
                    {
                        return(parent.SqlViewPropertyList[DataHelper.GetRandomInt(0, parent.SqlViewPropertyList.Count - 1)]);
                    }
                }
                #region protected
                else if (solutionContext.IsSampleMode == true && modelContext is DatabaseSource)
                {
                    SqlDatabase parent = (modelContext as DatabaseSource).SpecDatabase;
                    if (parent != null && parent.SqlViewList.Count > 0)
                    {
                        return(parent.SqlViewList[0].SqlViewPropertyList[DataHelper.GetRandomInt(0, parent.SqlViewList[0].SqlViewPropertyList.Count - 1)]);
                    }
                }
                else if (solutionContext.IsSampleMode == true && modelContext is Project)
                {
                    SqlDatabase parent = (modelContext as Project).OutputDatabase;
                    if (parent != null && parent.SqlViewList.Count > 0)
                    {
                        return(parent.SqlViewList[0].SqlViewPropertyList[DataHelper.GetRandomInt(0, parent.SqlViewList[0].SqlViewPropertyList.Count - 1)]);
                    }
                }
                #endregion protected

                if (modelContext is Solution)
                {
                    break;
                }
                modelContext = modelContext.GetParentItem();
            }

            #region protected
            #endregion protected

            isValidContext = false;
            return(null);
        }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         IDomainEnterpriseObject withModelContext = GetModelContext(solutionContext, templateContext, modelContext, interpreterType);
         templateContext.PushModelContext(withModelContext);
         templateContext.IsBreaking = false;
         if (withModelContext != null)
         {
             foreach (IStatementNode node in Statements)
             {
                 if (node.HandleDebug(interpreterType, solutionContext, templateContext, withModelContext) == false)
                 {
                     return;
                 }
                 if (templateContext.IsBreaking == true || templateContext.IsReturning == true)
                 {
                     templateContext.IsBreaking = false;
                     break;
                 }
                 if (node is BreakStatementNode)
                 {
                     templateContext.IsBreaking = true;
                     break;
                 }
                 if (node is ContinueStatementNode)
                 {
                     templateContext.IsContinuing = true;
                 }
                 if (node is ReturnStatementNode)
                 {
                     templateContext.IsReturning = true;
                     break;
                 }
                 node.InterpretNode(interpreterType, solutionContext, templateContext, withModelContext);
             }
         }
         templateContext.PopModelContext();
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Exemplo n.º 12
0
        ///--------------------------------------------------------------------------------
        /// <summary>Handle breakpoint.</summary>
        ///
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="lineNumber">The associated line number.</param>
        ///--------------------------------------------------------------------------------
        public void HandleBreakpoint(InterpreterTypeCode interpreterType, IDomainEnterpriseObject modelContext, int lineNumber)
        {
            SolutionDebugEventArgs args = new SolutionDebugEventArgs();

            args.InterpreterType = interpreterType;
            args.Solution        = Solution;
            args.TemplateContext = SpecTemplate;
            args.ModelContext    = modelContext;
            args.LineNumber      = lineNumber;
            if (interpreterType == InterpreterTypeCode.Content)
            {
                OnContentBreakpointReached(this, args);
            }
            else if (interpreterType == InterpreterTypeCode.Output)
            {
                OnOutputBreakpointReached(this, args);
            }
        }
Exemplo n.º 13
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the collection context associated with this item.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="modelContext">The associated model context.</param>
        ///--------------------------------------------------------------------------------
        public static IEnterpriseEnumerable GetCollectionContext(Solution solutionContext, IDomainEnterpriseObject modelContext)
        {
            IDomainEnterpriseObject nodeContext = modelContext;

            while (nodeContext != null)
            {
                if (nodeContext is Solution)
                {
                    return((nodeContext as Solution).ModelList);
                }

                #region protected
                #endregion protected

                nodeContext = nodeContext.GetParentItem();
            }
            return(null);
        }
Exemplo n.º 14
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the current model context for the item.</summary>
        ///
        /// <param name="parentModelContext">The parent model context from which to get current model context.</param>
        /// <param name="isValidContext">Output flag, signifying whether context returned is a valid one.</param>
        ///--------------------------------------------------------------------------------
        public static IDomainEnterpriseObject GetModelContext(Solution solutionContext, IDomainEnterpriseObject parentModelContext, out bool isValidContext)
        {
            isValidContext = true;
            IDomainEnterpriseObject modelContext = parentModelContext;

            while (modelContext != null)
            {
                if (modelContext is Model)
                {
                    return(modelContext);
                }
                else if (solutionContext.IsSampleMode == true && solutionContext.NeedsSample == true && modelContext is Solution)
                {
                    solutionContext.NeedsSample = false;
                    Solution parent = modelContext as Solution;
                    if (parent.ModelList.Count > 0)
                    {
                        return(parent.ModelList[DataHelper.GetRandomInt(0, parent.ModelList.Count - 1)]);
                    }
                }
                #region protected
                #endregion protected

                if (modelContext is Solution)
                {
                    break;
                }
                modelContext = modelContext.GetParentItem();
            }
            if (solutionContext.IsSampleMode == true && solutionContext.NeedsSample == true && solutionContext.ModelList.Count > 0)
            {
                solutionContext.NeedsSample = false;
                return(solutionContext.ModelList[DataHelper.GetRandomInt(0, solutionContext.ModelList.Count - 1)]);
            }
            isValidContext = false;
            return(null);
        }
Exemplo n.º 15
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the current model context for the item.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="objectName">The name of the model object type.</param>
        /// <param name="parentModelContext">The parent model context from which to get current model context.</param>
        /// <param name="isValidContext">Output flag, signifying whether context returned is a valid one.</param>
        ///--------------------------------------------------------------------------------
        public static IDomainEnterpriseObject GetModelContext(Solution solutionContext, string objectName, IDomainEnterpriseObject parentModelContext, out bool isValidContext)
        {
            isValidContext = true;
            IDomainEnterpriseObject modelContext = parentModelContext;

            while (modelContext != null)
            {
                if (modelContext is ObjectInstance && (modelContext as ObjectInstance).ModelObjectName == objectName)
                {
                    return(modelContext as ObjectInstance);
                }

                if (modelContext is Solution)
                {
                    break;
                }
                if (modelContext is ObjectInstance)
                {
                    modelContext = (modelContext as ObjectInstance).GetParentItem(objectName);
                }
                else
                {
                    modelContext = modelContext.GetParentItem();
                }
            }
            if (solutionContext.IsSampleMode == true)
            {
                if (solutionContext.ObjectInstanceList.Count > 0)
                {
                    return(solutionContext.ObjectInstanceList[DataHelper.GetRandomInt(0, solutionContext.ObjectInstanceList.Count - 1)]);
                }
            }

            isValidContext = false;
            return(null);
        }
Exemplo n.º 16
0
 ///--------------------------------------------------------------------------------
 /// <summary>Handle debugging workflow.</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public bool HandleDebug(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     if (DebugHelper.DebugAction == DebugAction.Stop)
     {
         // cause subsequent statements to not execute
         return(false);
     }
     if (solutionContext.IsSampleMode == true)              // only allow debugging from designer side using sample mode
     {
         if (interpreterType == InterpreterTypeCode.Content)
         {
             if (templateContext.ContentBreakpoints.Contains(LineNumber) == true && DebugHelper.DebugAction != DebugAction.Breaking)
             {
                 // handle breakpoint
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     DebugHelper.DebugAction = DebugAction.Breaking;
                 }
                 // fire breaking event
                 solutionContext.HandleBreakpoint(interpreterType, templateContext, modelContext, LineNumber);
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     while (DebugHelper.DebugAction == DebugAction.Breaking)
                     {
                         Monitor.Wait(DebugHelper.DEBUG_OBJECT);
                     }
                 }
                 if (DebugHelper.DebugAction == DebugAction.Stop)
                 {
                     // cause subsequent statements to not execute
                     return(false);
                 }
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     DebugHelper.DebugAction = DebugAction.Continue;
                 }
             }
         }
         else if (interpreterType == InterpreterTypeCode.Output)
         {
             if (templateContext.OutputBreakpoints.Contains(LineNumber) == true && DebugHelper.DebugAction != DebugAction.Breaking)
             {
                 // handle breakpoint
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     DebugHelper.DebugAction = DebugAction.Breaking;
                 }
                 // fire breaking event
                 solutionContext.HandleBreakpoint(interpreterType, templateContext, modelContext, LineNumber);
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     while (DebugHelper.DebugAction == DebugAction.Breaking)
                     {
                         Monitor.Wait(DebugHelper.DEBUG_OBJECT);
                     }
                 }
                 if (DebugHelper.DebugAction == DebugAction.Stop)
                 {
                     // cause subsequent statements to not execute
                     return(false);
                 }
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     DebugHelper.DebugAction = DebugAction.Continue;
                 }
             }
         }
     }
     return(true);
 }
Exemplo n.º 17
0
        ///--------------------------------------------------------------------------------
        /// <summary>Show a trace message associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="messageBody">The main body message to show.</param>
        /// <param name="showMessageBox">Flag indicating whether message box should be displayed in addition to output area.</param>
        ///--------------------------------------------------------------------------------
        public string ShowTraceMessage(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, string messageBody, bool showMessageBox = false)
        {
            StringBuilder message = new StringBuilder();

            message.Append(messageBody);
            message.Append(", ");
            message.Append(DisplayValues.Exception_SolutionIntro);
            message.Append(" ");
            message.Append(solutionContext.SolutionName);
            message.Append(", ");
            message.Append(DisplayValues.Exception_NodeIntro);
            message.Append(" ");
            message.Append(templateContext.NodeName);
            message.Append(", ");
            message.Append(DisplayValues.Exception_TemplateIntro);
            message.Append(" ");
            message.Append(templateContext.TemplateName);
            message.Append(", ");
            message.Append(DisplayValues.Exception_LineNumberIntro);
            message.Append(" ");
            message.Append(LineNumber.ToString());
            message.Append(", ");
            message.Append(DisplayValues.Exception_ModelContextIntro);
            message.Append(" ");
            message.Append(modelContext.GetType().Name);
            message.Append(", ");
            message.Append(DisplayValues.Exception_ModelIdIntro);
            message.Append(" ");
            message.Append(modelContext.ID.ToString());
            solutionContext.ShowOutput(message.ToString(), null, true, showMessageBox);
            return(message.ToString());
        }
Exemplo n.º 18
0
 ///--------------------------------------------------------------------------------
 /// <summary>Log an exception associated with this node.</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 /// <param name="messageBody">The main body message to show.</param>
 /// <param name="interpreterType">The interpreter type, such as content or output.</param>
 ///--------------------------------------------------------------------------------
 public string LogException(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, string messageBody, InterpreterTypeCode interpreterType = InterpreterTypeCode.None)
 {
     return(templateContext.LogException(solutionContext, modelContext, messageBody, LineNumber, interpreterType));
 }
Exemplo n.º 19
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
 }
Exemplo n.º 20
0
        ///--------------------------------------------------------------------------------
        /// <summary>Evaluate expression associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        ///--------------------------------------------------------------------------------
        public bool EvaluateExpression(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, InterpreterTypeCode interpreterType)
        {
            string value = GetExpressionValue(solutionContext, templateContext, modelContext, interpreterType);

            if (String.IsNullOrEmpty(value) || value == "false")
            {
                return(false);
            }
            return(true);
        }
        ///--------------------------------------------------------------------------------
        /// <summary>Interpret this node to produce code, output, or model data..</summary>
        ///
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        ///--------------------------------------------------------------------------------
        public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
        {
            try
            {
                string text;
                if (CustomText != null)
                {
                    text = CustomText.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
                }
                else
                {
                    text = templateContext.ContentCodeBuilder.ToString();
                }
                string path = FilePath.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
                if (!String.IsNullOrEmpty(text) && !String.IsNullOrEmpty(path))
                {
                    if (solutionContext.IsSampleMode == true)
                    {
                        // don't perform replacement of output files, just indicate it would be output
                        templateContext.MessageBuilder.Append("\r\n> ");
                        templateContext.MessageBuilder.Append(path);
                    }
                    else if (solutionContext.LoggedErrors.Count == 0)
                    {
                        if (File.Exists(path) == true)
                        {
                            if (solutionContext.UseProtectedAreas == true && String.IsNullOrEmpty(solutionContext.ProtectedAreaStart) == false && String.IsNullOrEmpty(solutionContext.ProtectedAreaEnd) == false)
                            {
                                // preserve protected areas in output file
                                string originalText = FileHelper.GetText(path);
                                if (originalText.Contains(solutionContext.ProtectedAreaStart) && originalText.Contains(solutionContext.ProtectedAreaEnd))
                                {
                                    int           currentTextIndex         = 0;
                                    int           currentOriginalTextIndex = 0;
                                    bool          hasProtectedText         = false;
                                    StringBuilder updatedText = new StringBuilder();
                                    while (currentTextIndex < (text.Length - 1))
                                    {
                                        if (text.IndexOf(solutionContext.ProtectedAreaStart, currentTextIndex) >= 0 && text.IndexOf(solutionContext.ProtectedAreaEnd, text.IndexOf(solutionContext.ProtectedAreaStart, currentTextIndex)) >= 0)
                                        {
                                            // append text to next protected block
                                            updatedText.Append(text.Substring(currentTextIndex, text.IndexOf(solutionContext.ProtectedAreaStart, currentTextIndex) - currentTextIndex));
                                            currentTextIndex = text.IndexOf(solutionContext.ProtectedAreaStart, currentTextIndex);

                                            if (originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex) >= 0 && originalText.IndexOf(solutionContext.ProtectedAreaEnd, originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex)) >= 0)
                                            {
                                                hasProtectedText         = true;
                                                currentOriginalTextIndex = originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex);
                                                if (String.IsNullOrWhiteSpace(originalText.Substring(currentOriginalTextIndex + solutionContext.ProtectedAreaStart.Length, originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) - currentOriginalTextIndex - solutionContext.ProtectedAreaStart.Length)))
                                                {
                                                    hasProtectedText = false;
                                                }
                                                if (hasProtectedText == true)
                                                {
                                                    // append protected block in original text
                                                    updatedText.Append(originalText.Substring(currentOriginalTextIndex, originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) - currentOriginalTextIndex + solutionContext.ProtectedAreaEnd.Length));
                                                }
                                                else
                                                {
                                                    // append protected block in generated text
                                                    updatedText.Append(text.Substring(currentTextIndex, text.IndexOf(solutionContext.ProtectedAreaEnd, currentTextIndex) - currentTextIndex + solutionContext.ProtectedAreaEnd.Length));
                                                }
                                                currentOriginalTextIndex = originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) + solutionContext.ProtectedAreaEnd.Length;

                                                // skip protected block in text
                                                currentTextIndex = text.IndexOf(solutionContext.ProtectedAreaEnd, currentTextIndex) + solutionContext.ProtectedAreaEnd.Length;
                                            }
                                            else
                                            {
                                                // append remainder of text to updated text
                                                updatedText.Append(text.Substring(currentTextIndex));
                                                currentTextIndex = text.Length - 1;
                                            }
                                        }
                                        else
                                        {
                                            // append remainder of text to updated text
                                            updatedText.Append(text.Substring(currentTextIndex));
                                            currentTextIndex = text.Length - 1;

                                            // append remainder of protected blocks in original text (if any, user will have to move/replace these blocks)
                                            while (originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex) >= 0 && originalText.IndexOf(solutionContext.ProtectedAreaEnd, originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex)) >= 0)
                                            {
                                                hasProtectedText         = true;
                                                currentOriginalTextIndex = originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex);
                                                if (String.IsNullOrWhiteSpace(originalText.Substring(currentOriginalTextIndex + solutionContext.ProtectedAreaStart.Length, originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) - currentOriginalTextIndex - solutionContext.ProtectedAreaStart.Length)))
                                                {
                                                    hasProtectedText = false;
                                                }
                                                if (hasProtectedText == true)
                                                {
                                                    updatedText.Append(originalText.Substring(currentOriginalTextIndex, originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) - currentOriginalTextIndex + solutionContext.ProtectedAreaEnd.Length));
                                                }
                                                currentOriginalTextIndex = originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) + solutionContext.ProtectedAreaEnd.Length;
                                            }
                                        }
                                    }
                                    FileHelper.ReplaceFile(path, updatedText.ToString());
                                }
                                else
                                {
                                    // replace file if protected tags not found
                                    FileHelper.ReplaceFile(path, text);
                                }
                            }
                            else
                            {
                                // replace file wholesale
                                FileHelper.ReplaceFile(path, text);
                            }
                        }
                        else
                        {
                            string directory = Directory.GetParent(path).FullName;
                            if (!Directory.Exists(directory))
                            {
                                Directory.CreateDirectory(directory);
                            }
                            FileHelper.CreateFile(path, text);
                        }
                    }
                }
            }
            catch (ApplicationAbortException)
            {
                throw;
            }
            catch (System.Exception ex)
            {
                LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
            }
        }
Exemplo n.º 22
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the content for a watch expression.</summary>
        ///
        /// <param name="watchExpression">Expression to evaluate.</param>
        /// <param name="parentModelContext">The parent model context from which to generate code.</param>
        ///
        /// <returns>A string representing the generated code for the watch expression.</returns>
        ///--------------------------------------------------------------------------------
        public string GetWatchContent(string watchExpression, IDomainEnterpriseObject parentModelContext)
        {
            try
            {
                SpecTemplate template = Solution.SpecTemplates[TemplateKey] as SpecTemplate;
                if (template == null)
                {
                    return(String.Empty);
                }

                // handle special cases
                if (String.IsNullOrEmpty(watchExpression))
                {
                    return(String.Empty);
                }
                if (watchExpression == LanguageTerms.TextProperty)
                {
                    return(template.ContentCodeBuilder.ToString());
                }
                if (watchExpression == LanguageTerms.PathProperty)
                {
                    return(template.OutputCodeBuilder.ToString());
                }

                // create temporary template
                SpecTemplate watchTemplate = new SpecTemplate();
                watchTemplate.Solution        = Solution;
                watchTemplate.NodeName        = parentModelContext.GetType().Name;
                watchTemplate.IsWatchTemplate = true;

                // wrap input expression into a template with a single property
                watchTemplate.TemplateContent = LanguageTerms.PropOpenTag + watchExpression + LanguageTerms.CloseTag;

                // push parameters and variables onto watch template
                if (template != null)
                {
                    foreach (string key in template.Parameters.AllKeys)
                    {
                        watchTemplate.Parameters[key] = template.Parameters[key];
                    }
                    foreach (string key in template.Variables.AllKeys)
                    {
                        watchTemplate.Variables[key] = template.Variables[key];
                    }
                }

                // push template context stack onto watch template as needed
                if (template != null && template.ModelContextStack.Count > 1)
                {
                    for (int i = template.ModelContextStack.Count - 1; i > 0; i--)
                    {
                        watchTemplate.PushModelContext(template.ModelContextStack[i]);
                    }
                }

                // get expression value
                string watchValue = watchTemplate.GetContent(parentModelContext);
                if (watchTemplate.HasErrors == true)
                {
                    watchValue = DisplayValues.Exception_WatchExpression;
                }
                return(watchValue);
            }
            catch (ApplicationAbortException ex)
            {
                return(ex.Message);
            }
            catch (System.Exception ex)
            {
                return(ex.Message);
            }
        }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         if (CurrentItem != null)
         {
             if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentAuditProperty))
             {
                 if (solutionContext.CurrentAuditProperty != null)
                 {
                     AuditProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- AuditProperty: ").Append(solutionContext.CurrentAuditProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentCollection))
             {
                 if (solutionContext.CurrentCollection != null)
                 {
                     Collection.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Collection: ").Append(solutionContext.CurrentCollection.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentEntity))
             {
                 if (solutionContext.CurrentEntity != null)
                 {
                     Entity.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Entity: ").Append(solutionContext.CurrentEntity.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentEntityReference))
             {
                 if (solutionContext.CurrentEntityReference != null)
                 {
                     EntityReference.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- EntityReference: ").Append(solutionContext.CurrentEntityReference.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentEnumeration))
             {
                 if (solutionContext.CurrentEnumeration != null)
                 {
                     Enumeration.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Enumeration: ").Append(solutionContext.CurrentEnumeration.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentFeature))
             {
                 if (solutionContext.CurrentFeature != null)
                 {
                     Feature.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Feature: ").Append(solutionContext.CurrentFeature.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentIndex))
             {
                 if (solutionContext.CurrentIndex != null)
                 {
                     Index.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Index: ").Append(solutionContext.CurrentIndex.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentIndexProperty))
             {
                 if (solutionContext.CurrentIndexProperty != null)
                 {
                     IndexProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- IndexProperty: ").Append(solutionContext.CurrentIndexProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentMethod))
             {
                 if (solutionContext.CurrentMethod != null)
                 {
                     Method.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Method: ").Append(solutionContext.CurrentMethod.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentMethodRelationship))
             {
                 if (solutionContext.CurrentMethodRelationship != null)
                 {
                     MethodRelationship.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- MethodRelationship: ").Append(solutionContext.CurrentMethodRelationship.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentModel))
             {
                 if (solutionContext.CurrentModel != null)
                 {
                     Model.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Model: ").Append(solutionContext.CurrentModel.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentModelObject))
             {
                 if (solutionContext.CurrentModelObject != null)
                 {
                     ModelObject.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ModelObject: ").Append(solutionContext.CurrentModelObject.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentModelProperty))
             {
                 if (solutionContext.CurrentModelProperty != null)
                 {
                     ModelProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ModelProperty: ").Append(solutionContext.CurrentModelProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentObjectInstance))
             {
                 if (solutionContext.CurrentObjectInstance != null)
                 {
                     ObjectInstance.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ObjectInstance: ").Append(solutionContext.CurrentObjectInstance.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentParameter))
             {
                 if (solutionContext.CurrentParameter != null)
                 {
                     Parameter.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Parameter: ").Append(solutionContext.CurrentParameter.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentProject))
             {
                 if (solutionContext.CurrentProject != null)
                 {
                     Project.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Project: ").Append(solutionContext.CurrentProject.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentProperty))
             {
                 if (solutionContext.CurrentProperty != null)
                 {
                     Property.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Property: ").Append(solutionContext.CurrentProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentPropertyInstance))
             {
                 if (solutionContext.CurrentPropertyInstance != null)
                 {
                     PropertyInstance.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- PropertyInstance: ").Append(solutionContext.CurrentPropertyInstance.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentPropertyReference))
             {
                 if (solutionContext.CurrentPropertyReference != null)
                 {
                     PropertyReference.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- PropertyReference: ").Append(solutionContext.CurrentPropertyReference.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentPropertyRelationship))
             {
                 if (solutionContext.CurrentPropertyRelationship != null)
                 {
                     PropertyRelationship.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- PropertyRelationship: ").Append(solutionContext.CurrentPropertyRelationship.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentRelationship))
             {
                 if (solutionContext.CurrentRelationship != null)
                 {
                     Relationship.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Relationship: ").Append(solutionContext.CurrentRelationship.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentRelationshipProperty))
             {
                 if (solutionContext.CurrentRelationshipProperty != null)
                 {
                     RelationshipProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- RelationshipProperty: ").Append(solutionContext.CurrentRelationshipProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStage))
             {
                 if (solutionContext.CurrentStage != null)
                 {
                     Stage.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Stage: ").Append(solutionContext.CurrentStage.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStageTransition))
             {
                 if (solutionContext.CurrentStageTransition != null)
                 {
                     StageTransition.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StageTransition: ").Append(solutionContext.CurrentStageTransition.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentState))
             {
                 if (solutionContext.CurrentState != null)
                 {
                     State.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- State: ").Append(solutionContext.CurrentState.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStateModel))
             {
                 if (solutionContext.CurrentStateModel != null)
                 {
                     StateModel.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StateModel: ").Append(solutionContext.CurrentStateModel.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStateTransition))
             {
                 if (solutionContext.CurrentStateTransition != null)
                 {
                     StateTransition.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StateTransition: ").Append(solutionContext.CurrentStateTransition.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStep))
             {
                 if (solutionContext.CurrentStep != null)
                 {
                     Step.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Step: ").Append(solutionContext.CurrentStep.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStepTransition))
             {
                 if (solutionContext.CurrentStepTransition != null)
                 {
                     StepTransition.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StepTransition: ").Append(solutionContext.CurrentStepTransition.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentValue))
             {
                 if (solutionContext.CurrentValue != null)
                 {
                     Value.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Value: ").Append(solutionContext.CurrentValue.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentView))
             {
                 if (solutionContext.CurrentView != null)
                 {
                     View.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- View: ").Append(solutionContext.CurrentView.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentViewProperty))
             {
                 if (solutionContext.CurrentViewProperty != null)
                 {
                     ViewProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ViewProperty: ").Append(solutionContext.CurrentViewProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentWorkflow))
             {
                 if (solutionContext.CurrentWorkflow != null)
                 {
                     Workflow.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Workflow: ").Append(solutionContext.CurrentWorkflow.InnerXmlData);
                     }
                 }
             }
             #region protected
             #endregion protected
             else
             {
                 LogException(solutionContext, templateContext, modelContext, String.Format(DisplayValues.Exception_CouldNotDeleteItem, CurrentItem.CurrentItemName), interpreterType);
             }
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Exemplo n.º 24
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 /// <param name="appendToTemplateContext">Flag to append content.</param>
 /// <param name="parameters">Template parameters.</param>
 ///--------------------------------------------------------------------------------
 public void GenerateOutput(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, bool appendToTemplateContext, NameObjectCollection parameters)
 {
     ModelContextStack = null;
     PopCount          = 0;
     if (modelContext is Project)
     {
         BusinessConfiguration.CurrentProject = modelContext as Project;
     }
     PushModelContext(modelContext);
     OutputCodeBuilder.Clear();
     CurrentTabIndent = templateContext.CurrentTabIndent;
     if (OutputAST == null)
     {
         ParseOutput(Solution.IsSampleMode);
     }
     if (OutputAST != null)
     {
         OutputAST.InterpretNode(InterpreterTypeCode.Output, solutionContext, this, modelContext, parameters);
     }
     else
     {
         OutputCodeBuilder.Append("<" + TemplateName + ">");
     }
     if (appendToTemplateContext == true)
     {
         templateContext.OutputCodeBuilder.Append(ContentCodeBuilder.ToString());
     }
     ModelContextStack = null;
     PopCount          = 0;
 }
Exemplo n.º 25
0
        ///--------------------------------------------------------------------------------
        /// <summary>Evaluate expression associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        ///--------------------------------------------------------------------------------
        public string GetExpressionValue(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, InterpreterTypeCode interpreterType)
        {
            string expression1Value = String.Empty;

            if (Expression1 != null)
            {
                expression1Value = Expression1.GetExpressionValue(solutionContext, templateContext, modelContext, interpreterType);
            }
            string expression2Value = String.Empty;

            if (Expression2 != null)
            {
                expression2Value = Expression2.GetExpressionValue(solutionContext, templateContext, modelContext, interpreterType);
            }
            if (String.IsNullOrEmpty(expression1Value))
            {
                expression1Value = "null";
            }
            if (String.IsNullOrEmpty(expression2Value))
            {
                expression2Value = "null";
            }
            long   expression1Long;
            long   expression2Long;
            double expression1Double;
            double expression2Double;

            if (Literal != null)
            {
                return(Literal.RawValue);
            }
            if (ModelProperty != null)
            {
                return(ModelProperty.GetPropertyStringValue(solutionContext, templateContext, modelContext, modelContext, interpreterType));
            }
            if (ModelContext != null)
            {
                bool isValidContext;
                IDomainEnterpriseObject nodeContext = ModelContext.GetModelContext(solutionContext, templateContext, modelContext, out isValidContext);
                if (nodeContext == null)
                {
                    return("null");
                }
                else
                {
                    if (nodeContext.ID == Guid.Empty || nodeContext.ID == null)
                    {
                        return("null");
                    }
                    return(nodeContext.ID.ToString());
                }
            }
            else if (CurrentItem != null)
            {
                IDomainEnterpriseObject nodeContext = CurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
                if (nodeContext == null)
                {
                    return("null");
                }
                else
                {
                    return(nodeContext.ID.ToString());
                }
            }
            else if (SpecCurrentItem != null)
            {
                IDomainEnterpriseObject nodeContext = SpecCurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
                if (nodeContext == null)
                {
                    return("null");
                }
                else
                {
                    return(nodeContext.ID.ToString());
                }
            }
            else if (Expression1 != null && Expression2 != null)
            {
                if (BinaryOperator != null)
                {
                    switch (BinaryOperator.Operator)
                    {
                    case "||":
                        if (Expression1.EvaluateExpression(solutionContext, templateContext, modelContext, interpreterType) || Expression2.EvaluateExpression(solutionContext, templateContext, modelContext, interpreterType))
                        {
                            return("true");
                        }
                        return("false");

                    case "&&":
                        if (Expression1.EvaluateExpression(solutionContext, templateContext, modelContext, interpreterType) && Expression2.EvaluateExpression(solutionContext, templateContext, modelContext, interpreterType))
                        {
                            return("true");
                        }
                        return("false");

                    case "==":
                        if (expression1Value == expression2Value)
                        {
                            return("true");
                        }
                        return("false");

                    case "!=":
                        if (expression1Value != expression2Value)
                        {
                            return("true");
                        }
                        return("false");

                    case "<":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            if (expression1Long < expression2Long)
                            {
                                return("true");
                            }
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            if (expression1Double < expression2Double)
                            {
                                return("true");
                            }
                        }
                        else
                        {
                            if (expression1Value.Length < expression2Value.Length)
                            {
                                return("true");
                            }
                        }
                        return("false");

                    case ">":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            if (expression1Long > expression2Long)
                            {
                                return("true");
                            }
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            if (expression1Double > expression2Double)
                            {
                                return("true");
                            }
                        }
                        else
                        {
                            if (expression1Value.Length > expression2Value.Length)
                            {
                                return("true");
                            }
                        }
                        return("false");

                    case "<=":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            if (expression1Long <= expression2Long)
                            {
                                return("true");
                            }
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            if (expression1Double <= expression2Double)
                            {
                                return("true");
                            }
                        }
                        else
                        {
                            if (expression1Value.Length <= expression2Value.Length)
                            {
                                return("true");
                            }
                        }
                        return("false");

                    case ">=":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            if (expression1Long >= expression2Long)
                            {
                                return("true");
                            }
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            if (expression1Double >= expression2Double)
                            {
                                return("true");
                            }
                        }
                        else
                        {
                            if (expression1Value.Length >= expression2Value.Length)
                            {
                                return("true");
                            }
                        }
                        return("false");

                    default:
                        return("false");
                    }
                }
                else if (MathOperator != null)
                {
                    switch (MathOperator.Operator)
                    {
                    case "+":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            return((expression1Long + expression2Long).ToString());
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            return((expression1Double + expression2Double).ToString());
                        }
                        else
                        {
                            return(expression1Value + expression2Value);
                        }

                    case "-":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            return((expression1Long - expression2Long).ToString());
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            return((expression1Double - expression2Double).ToString());
                        }
                        else
                        {
                            return(expression1Value.Replace(expression2Value, ""));
                        }

                    case "*":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            return((expression1Long * expression2Long).ToString());
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            return((expression1Double * expression2Double).ToString());
                        }
                        break;

                    case "/":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true && expression2Long != 0)
                        {
                            return((expression1Long / expression2Long).ToString());
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true && expression2Double != 0.00)
                        {
                            return((expression1Double / expression2Double).ToString());
                        }
                        break;

                    default:
                        break;
                    }
                    return("null");
                }
            }
            else if (Expression1 != null)
            {
                return(Expression1.GetExpressionValue(solutionContext, templateContext, modelContext, interpreterType));
            }
            return("null");
        }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         TemplateProperty.InterpretContentAndOutput(solutionContext, templateContext, modelContext, modelContext);
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the collection context associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="collectionType">The type of collection to get.</param>
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        ///--------------------------------------------------------------------------------
        public IEnterpriseEnumerable GetCollection(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, ModelContextNode collectionType, InterpreterTypeCode interpreterType)
        {
            IDomainEnterpriseObject collectionContext = modelContext;

            if (ModelContext != null)
            {
                bool isValidContext;
                collectionContext = ModelContext.GetModelContext(solutionContext, templateContext, modelContext, out isValidContext);
            }
            else if (CurrentItem != null)
            {
                collectionContext = CurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
            }
            else if (SpecCurrentItem != null)
            {
                collectionContext = SpecCurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
            }
            if (MethodName == LanguageTerms.FindAllMethod && ModelProperty != null)
            {
                IEnterpriseEnumerable collection = collectionType.GetCollection(solutionContext, templateContext, collectionContext);
                if (collection != null)
                {
                    return(collection.FindItems(ModelProperty.ModelPropertyName, Parameter.GetObjectValue(solutionContext, templateContext, modelContext, interpreterType)));
                }
            }
            else if (MethodName == LanguageTerms.GetEntityAndBasesCollection)
            {
                // TODO: condense ability to get extended collections
                if (collectionType.ModelContextName == "Entity" && collectionContext is Entity)
                {
                    EnterpriseDataObjectList <Entity> entities = new EnterpriseDataObjectList <Entity>();
                    Entity currentEntity = collectionContext as Entity;
                    while (currentEntity != null)
                    {
                        entities.Add(currentEntity);
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(entities);
                }
                else if (collectionType.ModelContextName == "Property")
                {
                    EnterpriseDataObjectList <Property> items = new EnterpriseDataObjectList <Property>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Property loopItem in currentEntity.PropertyList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "PropertyReference")
                {
                    EnterpriseDataObjectList <PropertyReference> items = new EnterpriseDataObjectList <PropertyReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (PropertyReference loopItem in currentEntity.PropertyReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "EntityReference")
                {
                    EnterpriseDataObjectList <EntityReference> items = new EnterpriseDataObjectList <EntityReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (EntityReference loopItem in currentEntity.EntityReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Collection")
                {
                    EnterpriseDataObjectList <Collection> items = new EnterpriseDataObjectList <Collection>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Collection loopItem in currentEntity.CollectionList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Relationship")
                {
                    EnterpriseDataObjectList <Relationship> items = new EnterpriseDataObjectList <Relationship>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Relationship loopItem in currentEntity.RelationshipList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Index")
                {
                    EnterpriseDataObjectList <Index> items = new EnterpriseDataObjectList <Index>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Index loopItem in currentEntity.IndexList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Method")
                {
                    EnterpriseDataObjectList <Method> items = new EnterpriseDataObjectList <Method>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Method loopItem in currentEntity.MethodList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
            }
            else if (MethodName == LanguageTerms.GetBaseAndEntitiesCollection)
            {
                // TODO: condense ability to get extended collections
                if (collectionType.ModelContextName == "Entity" && collectionContext is Entity)
                {
                    EnterpriseDataObjectList <Entity> items = new EnterpriseDataObjectList <Entity>();
                    Entity currentEntity = collectionContext as Entity;
                    while (currentEntity != null)
                    {
                        items.Insert(0, currentEntity);
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Property")
                {
                    EnterpriseDataObjectList <Property> items = new EnterpriseDataObjectList <Property>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Property loopItem in currentEntity.PropertyList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "PropertyReference")
                {
                    EnterpriseDataObjectList <PropertyReference> items = new EnterpriseDataObjectList <PropertyReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (PropertyReference loopItem in currentEntity.PropertyReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "EntityReference")
                {
                    EnterpriseDataObjectList <EntityReference> items = new EnterpriseDataObjectList <EntityReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (EntityReference loopItem in currentEntity.EntityReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Collection")
                {
                    EnterpriseDataObjectList <Collection> items = new EnterpriseDataObjectList <Collection>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Collection loopItem in currentEntity.CollectionList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Relationship")
                {
                    EnterpriseDataObjectList <Relationship> items = new EnterpriseDataObjectList <Relationship>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Relationship loopItem in currentEntity.RelationshipList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Index")
                {
                    EnterpriseDataObjectList <Index> items = new EnterpriseDataObjectList <Index>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Index loopItem in currentEntity.IndexList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Method")
                {
                    EnterpriseDataObjectList <Method> items = new EnterpriseDataObjectList <Method>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Method loopItem in currentEntity.MethodList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
            }
            else if (MethodName == LanguageTerms.ExtendingEntitiesCollection)
            {
                if (collectionType.ModelContextName == "Entity" && collectionContext is Entity)
                {
                    return((collectionContext as Entity).ExtendingEntites);
                }
                else if (collectionType.ModelContextName == "Property")
                {
                    EnterpriseDataObjectList <Property> items = new EnterpriseDataObjectList <Property>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Property loopItem in loopEntity.PropertyList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "PropertyReference")
                {
                    EnterpriseDataObjectList <PropertyReference> items = new EnterpriseDataObjectList <PropertyReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (PropertyReference loopItem in loopEntity.PropertyReferenceList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "EntityReference")
                {
                    EnterpriseDataObjectList <EntityReference> items = new EnterpriseDataObjectList <EntityReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (EntityReference loopItem in loopEntity.EntityReferenceList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Collection")
                {
                    EnterpriseDataObjectList <Collection> items = new EnterpriseDataObjectList <Collection>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Collection loopItem in loopEntity.CollectionList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Relationship")
                {
                    EnterpriseDataObjectList <Relationship> items = new EnterpriseDataObjectList <Relationship>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Relationship loopItem in loopEntity.RelationshipList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Index")
                {
                    EnterpriseDataObjectList <Index> items = new EnterpriseDataObjectList <Index>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Index loopItem in loopEntity.IndexList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Method")
                {
                    EnterpriseDataObjectList <Method> items = new EnterpriseDataObjectList <Method>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Method loopItem in loopEntity.MethodList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
            }
            else if (MethodName == LanguageTerms.PathRelationships)
            {
                if (collectionType.ModelContextName == "Relationship" && collectionContext is Entity)
                {
                    return((collectionContext as Entity).PathRelationships);
                }
            }
            return(null);
        }
Exemplo n.º 28
0
 ///--------------------------------------------------------------------------------
 /// <summary>Log an exception associated with this node.</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 /// <param name="ex">The exception to show.</param>
 /// <param name="interpreterType">The interpreter type, such as content or output.</param>
 ///--------------------------------------------------------------------------------
 public string LogException(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, System.Exception ex, InterpreterTypeCode interpreterType = InterpreterTypeCode.None)
 {
     return(LogException(solutionContext, templateContext, modelContext, ex.Message + "\r\n" + ex.StackTrace, interpreterType));
 }
Exemplo n.º 29
0
        ///--------------------------------------------------------------------------------
        /// <summary>Interpret this node to produce content.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="appendToTemplateContext">Flag to append content.</param>
        /// <param name="parameters">Template parameters.</param>
        ///--------------------------------------------------------------------------------
        public void GenerateContent(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, bool appendToTemplateContext, NameObjectCollection parameters)
        {
            ModelContextStack = null;
            PopCount          = 0;
            if (modelContext is Project)
            {
                BusinessConfiguration.CurrentProject = modelContext as Project;
            }
            PushModelContext(modelContext);
            MessageBuilder.Clear();
            ContentCodeBuilder.Clear();
            Parameters.Clear();
            Variables.Clear();
            CurrentTabIndent = templateContext.CurrentTabIndent;
            if (ContentAST == null && TemplateContent != String.Empty)
            {
                ParseContent(Solution.IsSampleMode);
            }
            if (Solution.UseTemplateCache == true && Solution.IsSampleMode == false && String.IsNullOrEmpty(TemplateOutput) && !String.IsNullOrEmpty(TemplateContent) && modelContext != null && CachedContent[modelContext.ID.ToString()] != null)
            {
                // use cached content
                solutionContext.TemplatesExecuted++;
                solutionContext.CachedTemplatesExecuted++;
                ContentCodeBuilder.Append(CachedContent[modelContext.ID.ToString()] as String);
            }
            else
            {
                if (ContentAST != null)
                {
                    ContentAST.InterpretNode(InterpreterTypeCode.Content, solutionContext, this, modelContext, parameters);
                }
                else
                {
                    ContentCodeBuilder.Append("<" + TemplateName + ">");
                }
            }
            if (Solution.UseTemplateCache == true && Solution.IsSampleMode == false && String.IsNullOrEmpty(TemplateOutput))
            {
                CachedContent[modelContext.ID.ToString()] = null;

                // only cache smaller content that has no parameters or config settings
                if (Parameters.Count == 0 && HasRelativeSettings == false && ContentCodeBuilder.Length <= Solution.TemplateCacheMaxContentSize)
                {
                    CachedContent[modelContext.ID.ToString()] = ContentCodeBuilder.ToString();
                }
            }
            if (appendToTemplateContext == true)
            {
                templateContext.ContentCodeBuilder.Append(ContentCodeBuilder.ToString());
            }
            ModelContextStack = null;
            PopCount          = 0;
        }
Exemplo n.º 30
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         solutionContext.PutStringLoggedValue(Parameter1.GetStringValue(solutionContext, templateContext, modelContext, interpreterType), Parameter2.GetStringValue(solutionContext, templateContext, modelContext, interpreterType), Parameter3.GetStringValue(solutionContext, templateContext, modelContext, interpreterType));
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }