Exemplo n.º 1
0
        private void GenerateCode(GenerationParameter parameter, ITemplateEngine templateEngine, string templateName,
                                  ref int genratedCount, ref int errorCount, ref int progressCount, AsyncOperation asyncOp)
        {
            foreach (string modelId in parameter.GenerationObjects.Keys)
            {
                string codeFileNamePath = PathHelper.GetCodeFileNamePath(ConfigManager.GenerationCodeOuputPath,
                                                                         ConfigManager.SettingsSection.Languages[parameter.Settings.Language].Alias,
                                                                         ConfigManager.SettingsSection.TemplateEngines[parameter.Settings.TemplateEngine].Name,
                                                                         ConfigManager.TemplateSection.Templates[templateName].DisplayName, parameter.Settings.Package, modelId);
                PathHelper.CreateCodeFileNamePath(codeFileNamePath);

                foreach (string objId in parameter.GenerationObjects[modelId])
                {
                    IMetaData    modelObject  = ModelManager.GetModelObject(parameter.Models[modelId], objId);
                    TemplateData templateData = TemplateDataBuilder.Build(modelObject, parameter.Settings,
                                                                          templateName, parameter.Models[modelId].Database, modelId);

                    if (templateData == null || !templateEngine.Run(templateData))
                    {
                        errorCount++;
                    }
                    else
                    {
                        genratedCount++;
                    }
                    string currentCodeFileName = templateData == null ? string.Empty : templateData.CodeFileName;

                    var args = new GenerationProgressChangedEventArgs(genratedCount,
                                                                      errorCount, currentCodeFileName, ++progressCount, asyncOp.UserSuppliedState);
                    asyncOp.Post(this.onProgressReportDelegate, args);
                }
            }
        }
Exemplo n.º 2
0
        private void GenerateCode(GenerationParameter parameter, ITemplateEngine templateEngine, string templateName,
            ref int genratedCount, ref int errorCount, ref int progressCount, AsyncOperation asyncOp)
        {
            foreach (string modelId in parameter.GenerationObjects.Keys)
            {
                string codeFileNamePath = PathHelper.GetCodeFileNamePath(ConfigManager.GenerationCodeOuputPath,
                    ConfigManager.SettingsSection.Languages[parameter.Settings.Language].Alias,
                    ConfigManager.SettingsSection.TemplateEngines[parameter.Settings.TemplateEngine].Name,
                    ConfigManager.TemplateSection.Templates[templateName].DisplayName, parameter.Settings.Package, modelId);
                PathHelper.CreateCodeFileNamePath(codeFileNamePath);

                foreach (string objId in parameter.GenerationObjects[modelId])
                {
                    IMetaData modelObject = ModelManager.GetModelObject(parameter.Models[modelId], objId);
                    TemplateData templateData = TemplateDataBuilder.Build(modelObject, parameter.Settings,
                            templateName, parameter.Models[modelId].Database, modelId);

                    if (templateData == null || !templateEngine.Run(templateData)) errorCount++; else genratedCount++;
                    string currentCodeFileName = templateData == null ? string.Empty : templateData.CodeFileName;

                    var args = new GenerationProgressChangedEventArgs(genratedCount,
                            errorCount, currentCodeFileName, ++progressCount, asyncOp.UserSuppliedState);
                    asyncOp.Post(this.onProgressReportDelegate, args);
                }
            }
        }