Beispiel #1
0
        private async Task <string> ProcessNewXsd(
            AltinnAppGitRepository altinnAppGitRepository,
            MemoryStream xsdMemoryStream,
            string filePath)
        {
            Json.Schema.JsonSchema jsonSchema = GenerateJsonSchemaFromXsd(xsdMemoryStream);
            var jsonContent = SerializeJson(jsonSchema);

            await altinnAppGitRepository.WriteTextByRelativePathAsync(
                Path.ChangeExtension(filePath, "schema.json"), jsonContent, true);

            var jsonSchemaConverterStrategy = JsonSchemaConverterStrategyFactory.SelectStrategy(jsonSchema);
            var metamodelConverter          =
                new JsonSchemaToMetamodelConverter(jsonSchemaConverterStrategy.GetAnalyzer());
            var schemaName    = GetSchemaName(filePath);
            var modelMetadata = metamodelConverter.Convert(schemaName, jsonContent);
            await altinnAppGitRepository.UpdateModelMetadata(modelMetadata, schemaName);

            await UpdateCSharpClasses(altinnAppGitRepository, modelMetadata, schemaName);

            await UpdateApplicationMetadata(altinnAppGitRepository, schemaName, schemaName);

            return(jsonContent);
        }
Beispiel #2
0
 private static async Task UpdateJsonSchema(AltinnAppGitRepository altinnAppGitRepository, string relativeFilePath, string jsonContent)
 {
     await altinnAppGitRepository.WriteTextByRelativePathAsync(relativeFilePath, jsonContent, true);
 }