Example #1
0
        /// <summary>
        /// Generates code files for the data object using each template 
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        public CodeFiles GenerateCode(TemplateData Data)
        {
            CodeFiles result = new CodeFiles();
            GenerationEventArgs e = new GenerationEventArgs() { DataObjectName = Data.DataContainerName };

            string type = Data.DataContainer.IsView ? "view" : "table";

            // generate code files for each template
            foreach (Template template in _templates.Where(t => t.IsInclude == false))
            {
                // only run templates for the right type of data object (ie. view or table)
                if (template.For.Contains(type))
                {
                    TemplateParser parser = new TemplateParser(template, Data, this);
                    CodeFile[] files = parser.ParseTemplate();
                    foreach (CodeFile file in files)
                        result.AddCodeFile(file);

                    e.TemplatesApplied.Add(template.FileName);
                    e.ParsingErrors.AddRange(parser.Exceptions);
                }

                // trigger the generated event
                OnCodeGenerated(e);
            }

            // merge in data common and safe reader
            result.Merge(GetDALCommonFiles(Data.RootNamespace));

            return result;
        }
Example #2
0
 /// <summary>
 /// Code was generated on a data object
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void gen_CodeGenerated(object sender, GenerationEventArgs e)
 {
 }
Example #3
0
 /// <summary>
 /// Invokes the code generated event
 /// </summary>
 /// <param name="e"></param>
 public virtual void OnCodeGenerated(GenerationEventArgs e)
 {
     if (CodeGenerated != null)
         CodeGenerated(this, e);
 }