Esempio n. 1
0
        public void Generate(IEnumerable <ClassDefinition> classDefinitions)
        {
            var classTemplate = TemplateReader.Read("ControllerTemplate.cs.txt");

            var addServiceCommands = new List <string>();

            foreach (var classDefinition in classDefinitions)
            {
                var domainObjectName = classDefinition.Name;
                var className        = domainObjectName + "Controller";

                classTemplate.TypeName = className;
                classTemplate.Set("[[DomainObjectName]]", domainObjectName);

                ProjectFileWriter.WriteToProject(
                    TargetFolderPath,
                    "WebApi",
                    "Controllers",
                    classTemplate);

                AppendAddServiceCommands(addServiceCommands, classDefinition);
            }

            GenerateStartupFile(addServiceCommands);
        }
Esempio n. 2
0
        public void Generate(IEnumerable <ClassDefinition> classDefinitions)
        {
            var interfaceTemplate = TemplateReader.Read("IServiceTemplate.cs.txt");
            var classTemplate     = TemplateReader.Read("ServiceTemplate.cs.txt");

            foreach (var classDefinition in classDefinitions)
            {
                var domainObjectName = classDefinition.Name;
                var className        = domainObjectName + "Service";
                var interfaceName    = "I" + className;

                interfaceTemplate.TypeName = interfaceName;
                interfaceTemplate.Set("[[DomainObjectName]]", domainObjectName);

                ProjectFileWriter.WriteToProject(
                    TargetFolderPath,
                    "Services",
                    null,
                    interfaceTemplate);

                classTemplate.TypeName = className;
                classTemplate.Set("[[DomainObjectName]]", domainObjectName);

                ProjectFileWriter.WriteToProject(
                    TargetFolderPath,
                    "Services",
                    null,
                    classTemplate);
            }
        }
Esempio n. 3
0
        private void GenerateStartupFile(List <string> addServiceCommands)
        {
            var startupTemplate = TemplateReader.Read("StartupTemplate.cs.txt");

            var startupLineSeparator = Environment.NewLine + "                ";

            var addServiceCommandString = string.Join(startupLineSeparator, addServiceCommands);

            startupTemplate.TypeName = "Startup";
            startupTemplate.Set("[[AddServiceCommands]]", addServiceCommandString);

            ProjectFileWriter.WriteToProject(
                TargetFolderPath,
                "WebApi",
                null,
                startupTemplate);
        }
Esempio n. 4
0
        public void Generate(IEnumerable <ClassDefinition> classDefinitions)
        {
            var template = TemplateReader.Read("ViewModelTemplate.cs.txt");

            foreach (var classDefinition in classDefinitions)
            {
                var propertiesString = CreatePropertiesString(classDefinition.Properties);

                var viewModelClassName = classDefinition.Name + "ViewModel";

                template.TypeName = viewModelClassName;
                template.Set("[[ClassName]]", viewModelClassName);
                template.Set("[[Properties]]", propertiesString);

                ProjectFileWriter.WriteToProject(
                    TargetFolderPath,
                    "ViewModels",
                    null,
                    template);
            }
        }
Esempio n. 5
0
        public void Generate(IEnumerable <ClassDefinition> classDefinitions)
        {
            var interfaceTemplate = TemplateReader.Read("IMapTemplate.cs.txt");
            var classTemplate     = TemplateReader.Read("MapTemplate.cs.txt");

            foreach (var classDefinition in classDefinitions)
            {
                var domainObjectName = classDefinition.Name;
                var className        = domainObjectName + "Map";
                var interfaceName    = "I" + className;

                interfaceTemplate.TypeName = interfaceName;
                interfaceTemplate.Set("[[DomainObjectName]]", domainObjectName);

                ProjectFileWriter.WriteToProject(
                    TargetFolderPath,
                    "Services",
                    null,
                    interfaceTemplate);

                classTemplate.TypeName = className;
                classTemplate.Set("[[DomainObjectName]]", domainObjectName);
                classTemplate.Set(
                    "[[DomainToViewModelMappings]]",
                    GenerateMappingString("domain", "viewModel", classDefinition.Properties));
                classTemplate.Set(
                    "[[ViewModelToDomainMappings]]",
                    GenerateMappingString("viewModel", "domain", classDefinition.Properties));

                ProjectFileWriter.WriteToProject(
                    TargetFolderPath,
                    "Services",
                    null,
                    classTemplate);
            }
        }