Exemplo n.º 1
0
        private void RenderDesignObjects(CodeDom.Module target, IEnumerable <DesignObject> designObjects)
        {
            if (designObjects == null)
            {
                return;
            }

            foreach (var designObject in designObjects)
            {
                var renderer = _renderersFactory.GetRenderer(designObject);
                renderer.Render(target, designObject);
            }
        }
Exemplo n.º 2
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}");
        }
Exemplo n.º 3
0
        private void RenderPoco(CodeDom.Module target, Entity entityDeclaration)
        {
            var entity = new EntityDeclaration
            {
                Name = entityDeclaration.Name
            };

            entity.Scope = entityDeclaration.Scope.Convert();
            target.TypeDeclarations.Add(entity);

            foreach (var member in entityDeclaration.Properties)
            {
                var entityField = new EntityField();
                entityField.Scope    = member.Scope.Convert();
                entityField.Name     = member.Name;
                entityField.Type     = member.Type.Convert();
                entityField.Required = member.Required;
                entityField.ReadOnly = member.ReadOnly;

                entity.Fields.Add(entityField);
            }
        }