Пример #1
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());
    }
    public async Task Output(AppApiTemplate appTemplate)
    {
        foreach (var group in appTemplate.GroupTemplates)
        {
            var controller          = createController(appTemplate, group);
            var controllerClassName = getControllerClassName(group);
            var cSharpFile          = new CSharpFile(controller, createStream, controllerClassName);
            await cSharpFile.Output();
        }
        var namespaces = appTemplate.ObjectTemplates(ApiCodeGenerators.Dotnet)
                         .Select(o => o.DataType.Namespace ?? "")
                         .Union
                         (
            new[]
        {
            "Microsoft.AspNetCore.Authorization",
            "Microsoft.AspNetCore.Mvc",
            "XTI_App.Api",
            "XTI_WebApp.Api"
        }
                         )
                         .Distinct()
                         .OrderBy(str => str)
                         .ToArray();

        await new GlobalUsingsClass(createStream, namespaces).Output();
    }
Пример #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();
    }