示例#1
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);
 }
示例#2
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;
 }
示例#3
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method generates the associated output path for the template.  By not
 /// supplying a model context, the generated code is generally suitable as a
 /// sample only.</summary>
 ///
 /// <returns>A string representing the generated code for the template.</returns>
 ///--------------------------------------------------------------------------------
 public string GenerateOutput()
 {
     try
     {
         return(GenerateOutput(GetMostRelevantSampleContext()));
     }
     catch (ApplicationAbortException)
     {
         // abort with whatever content is available
         OutputCode = OutputCodeBuilder.ToString() + MessageBuilder.ToString();
         return(OutputCode);
     }
 }