Example #1
0
    public async Task Output(AppApiTemplate appTemplate)
    {
        await generateApp(appTemplate);

        var formTemplates         = appTemplate.FormTemplates(ApiCodeGenerators.TypeScript);
        var complexFieldTemplates = formTemplates.SelectMany(ft => ft.Form.ComplexFieldTemplates).Distinct();

        foreach (var complexFieldTemplate in complexFieldTemplates)
        {
            await generateComplexField(complexFieldTemplate, false);
            await generateComplexFieldView(complexFieldTemplate, false);
        }
        foreach (var formTemplate in formTemplates)
        {
            await generateComplexField(formTemplate.Form, true);
            await generateComplexFieldView(formTemplate.Form, true);
        }
        foreach (var group in appTemplate.GroupTemplates)
        {
            await generateGroup(group);
        }
        await generateEntities(appTemplate);

        foreach (var numericValueTemplate in appTemplate.NumericValueTemplates(ApiCodeGenerators.TypeScript))
        {
            await generateNumericValue(numericValueTemplate);
        }
    }
Example #2
0
    private Task generateEntities(AppApiTemplate appTemplate)
    {
        var tsFile = new TypeScriptFile($"{appTemplate.Name}Entities.d.ts", createStream);

        tsFile.AddLine();
        foreach (var objectTemplate in appTemplate.ObjectTemplates(ApiCodeGenerators.TypeScript))
        {
            tsFile.AddLine($"interface I{objectTemplate.DataType.Name} {{");
            tsFile.Indent();
            foreach (var property in objectTemplate.PropertyTemplates)
            {
                var tsType = getTsType(property.ValueTemplate);
                tsFile.AddLine($"{property.Name}: {tsType};");
            }
            tsFile.Outdent();
            tsFile.AddLine("}");
        }
        foreach (var numericValueTemplate in appTemplate.NumericValueTemplates(ApiCodeGenerators.TypeScript))
        {
            tsFile.AddLine($"interface I{numericValueTemplate.DataType.Name} {{");
            tsFile.Indent();
            tsFile.AddLine($"Value: number;");
            tsFile.AddLine($"DisplayText: string;");
            tsFile.Outdent();
            tsFile.AddLine("}");
        }
        return(tsFile.Output());
    }
Example #3
0
    public async Task Output(AppApiTemplate appTemplate)
    {
        var objTemplates = appTemplate.ObjectTemplates(ApiCodeGenerators.Dotnet);

        foreach (var objTemplate in objTemplates)
        {
            await new ApiObjectClass(ns, createStream, objTemplate).Output();
        }
        var formTemplates         = appTemplate.FormTemplates(ApiCodeGenerators.Dotnet);
        var complexFieldTemplates = formTemplates.SelectMany(ft => ft.Form.ComplexFieldTemplates).Distinct();

        foreach (var complexFieldTemplate in complexFieldTemplates)
        {
            await new ComplexFieldClass(ns, createStream, complexFieldTemplate, "ComplexField").Output();
        }
        foreach (var formTemplate in formTemplates)
        {
            await new ComplexFieldClass(ns, createStream, formTemplate.Form, "Form").Output();
        }
        foreach (var groupTemplate in appTemplate.GroupTemplates)
        {
            await new ApiGroupClass(ns, createStream, groupTemplate).Output();
        }
        foreach (var numericValueTemplate in appTemplate.NumericValueTemplates(ApiCodeGenerators.Dotnet))
        {
            await new NumericValueClass(ns, createStream, numericValueTemplate).Output();
        }
        await new ApiAppClass(ns, createStream, appTemplate, versionKey).Output();
        var namespaces = new[]
        {
            "XTI_WebAppClient",
            "XTI_WebAppClient.Forms"
        };

        await new GlobalUsingsClass(createStream, namespaces).Output();
    }