Exemplo n.º 1
0
 private void GenerateBackendApiServices(WebUIMetadata metadata)
 {
     foreach (var api in metadata.BackendApis)
     {
         GenerateBackendApiService(api);
     }
 }
Exemplo n.º 2
0
 private void GeneratePageModules(WebUIMetadata metadata)
 {
     foreach (var page in metadata.Pages)
     {
         GeneratePageModule(page);
     }
 }
Exemplo n.º 3
0
        public void CanGenerateBackEndImplementation()
        {
            // arrange

            var workspace = LoadExampleWebAppWorkspace();

            // act

            var codeModel  = ReadCodeModel(workspace);
            var uiMetadata = new WebUIMetadata(codeModel);

            var output  = new TestCodeGeneratorOutput();
            var adapter = new AspNetAdapter(codeModel, output);

            adapter.GenerateImplementations(uiMetadata);

            // assert

            //WriteOutputToDisk(output, "BackEnd");
            AssertOutputs(
                output.IndexSourceFilesByNormalPath(),
                subFolder: "BackEnd",
                "AspNetAdapter/InvalidModelAutoResponderAttribute.cs",
                "App/Services/WebApi/GreetingServiceController.cs");
        }
Exemplo n.º 4
0
        public void CanGenerateFrontEndImplementation()
        {
            // arrange

            var workspace = LoadExampleWebAppWorkspace();

            // act

            var codeModel  = ReadCodeModel(workspace);
            var uiMetadata = new WebUIMetadata(codeModel);

            var output  = new TestCodeGeneratorOutput();
            var adapter = new HyperappAdapter(codeModel, new ComponentAdapterFactory(), output);

            adapter.GenerateImplementations(uiMetadata);

            // assert

            //WriteOutputToDisk(output, "FrontEnd");
            AssertOutputs(
                output.IndexSourceFilesByNormalPath(),
                subFolder: "FrontEnd",
                "build/index.html",
                "src/index.js",
                "src/components/form.js",
                "src/services/greeting-service.js");
        }
Exemplo n.º 5
0
 private void GenerateControllerTypes(WebUIMetadata ui)
 {
     foreach (var api in ui.BackendApis)
     {
         NAMESPACE($"{api.InterfaceType.Namespace}.WebApi", () => {
             WebApiControllerGenerator.WebApiController(_middlewareType, api);
         });
     }
 }
Exemplo n.º 6
0
        public void GenerateImplementations(WebUIMetadata metadata)
        {
            CopyFrameworkFiles();

            using (new CodeGeneratorContext(_codeModel, new ClrTypeResolver(), LanguageInfo.Entries.JavaScript()))
            {
                GenerateIndexHtml(metadata);
                GeneratePageModules(metadata);
                GenerateBackendApiServices(metadata);
            }
        }
Exemplo n.º 7
0
        public void GenerateImplementations(WebUIMetadata ui)
        {
            using (_context = new CodeGeneratorContext(_codeModel, new ClrTypeResolver(), LanguageInfo.Entries.CSharp()))
            {
                GenerateInfrastructureTypes();
                GenerateControllerTypes(ui);

                var writer = new RoslynCodeModelWriter(_codeModel, _output);
                writer.AddMembers(_context.GeneratedMembers);
                writer.WriteAll();
            }
        }
Exemplo n.º 8
0
        private void GenerateIndexHtml(WebUIMetadata metadata)
        {
            var html = new XDocument(
                new XDocumentType("html", null, null, null),
                new XElement("html",
                             new XElement("head",
                                          new XElement("meta", new XAttribute("charset", "utf-8")),
                                          new XElement("title", metadata.Pages.First().PageClass.Name.TrimSuffixFragment("Page").ToString()),
                                          new XElement("script",
                                                       new XAttribute("defer", true),
                                                       new XAttribute("src", "bundle.js"),
                                                       ""
                                                       )
                                          ),
                             new XElement("body", "")
                             )
                );

            _output.AddSourceFile(new[] { "build" }, "index.html", html.ToString());
        }