private void RenderModules(CodeDom.Project target, IEnumerable <Module> modules)
 {
     foreach (var module in modules)
     {
         _moduleRenderer.Render(target, module);
     }
 }
        public void RenderProject(Project project)
        {
            _renderLogger.Log(LogType.Info, $"Start rendering project: {project.Name}");

            var target = new CodeDom.Project
            {
            };

            RenderModules(target, project.Modules);
        }
Beispiel #3
0
        public void Render(CodeDom.Project target, Module module)
        {
            _renderLogger.Log(LogType.Info, $"Start rendering module: {module.ModuleName}");

            var renderedModule = new CodeDom.Module
            {
                Name             = module.ModuleName,
                Namespace        = module.Namespace,
                TypeDeclarations = new List <CodeDom.CodeTypeDeclaration>()
            };

            target.Modules.Add(renderedModule);

            RenderDesignObjects(renderedModule, module.DataModel.Enumerations);
            RenderDesignObjects(renderedModule, module.DataModel.Classes);
            RenderDesignObjects(renderedModule, module.DataModel.Entities);
            RenderDesignObjects(renderedModule, module.DataModel.Interfaces);

            _renderLogger.Log(LogType.Info, $"Finished rendering module: {module.ModuleName}");
        }
        public void GenerateCode(CodeDom.Project project, string targetSolution)
        {
            if (!_directory.Exists(Path.GetDirectoryName(targetSolution)))
            {
                _directory.CreateDirectory(Path.GetDirectoryName(targetSolution));
            }

            VisualStudioSolution solution = null;

            if (File.Exists(targetSolution))
            {
                solution = _visualStudioSolutionManager.Load(targetSolution, true);
            }
            else
            {
                solution = _visualStudioSolutionManager.CreateNew(targetSolution);
            }


            foreach (var module in project.Modules)
            {
                foreach (var typeDeclaration in module.TypeDeclarations)
                {
                    var vsProject     = ResolveProject(solution, typeDeclaration);
                    var vsProjectNode = ResolveProjectNode(vsProject, compileUnit);
                    var data          = GenerateCode(compileUnit);

                    vsProjectNode.GeneratedData = data;
                }

                _projectGenerator.AddBuildTargets(vsProject);
            }

            foreach (var application in project.Applications)
            {
            }

            _visualStudioSolutionManager.Save(solution);
        }