Esempio n. 1
0
        public void SetUp()
        {
            var retriever = new SwaggerRetriever(JsonMetadataTests.ApiMetadataConfiguration);

            var metadataRetriever = new SwaggerMetadataRetriever(
                JsonMetadataTests.ApiMetadataConfiguration, retriever,
                new List <string>());

            var jfactory = new JsonMetadataFactory(metadataRetriever);

            _jsonMetadata = jfactory.GetMetadata().ToList();

            var ssbuilder = new SchemaSetFactory(new XsdStreamsRetriever(JsonMetadataTests.XmlMetadataConfiguration));
            var xfactory  = new XsdMetadataFactory(ssbuilder.GetSchemaSet());

            _xmlMetadata = xfactory.GetMetadata().ToList();

            var strategies = new List <IMetadataMapper>
            {
                //new DiminishingMetadataMapper(),
                new PremappedLookupMetadataMapper(), new LookupDoNotMapPropertyMapper(),

                //new ArrayMetadataMapper(),
                new DescriptorReferenceMetadataMapper(), new NameMatchingMetadataMapper()

                //new SchoolIdBugFixMetadataMapper()
            };

            var factory = new LookupToGetByExampleMetadataMappingFactory(_xmlMetadata, _jsonMetadata, strategies);

            _mappings = factory.GetMetadataMappings().ToArray();
        }
        public void SetUp()
        {
            var retriever = new SwaggerRetriever(JsonMetadataTests.ApiMetadataConfiguration);

            var metadataRetriever = new SwaggerMetadataRetriever(
                JsonMetadataTests.ApiMetadataConfiguration, retriever,
                new List <string>());

            var ssbuilder = new SchemaSetFactory(new XsdStreamsRetriever(JsonMetadataTests.XmlMetadataConfiguration));
            var xfactory  = new XsdApiTypesMetadataFactory(ssbuilder.GetSchemaSet());

            _xmlMetadata = xfactory.GetMetadata().ToList();

            var jfactory = new JsonMetadataFactory(metadataRetriever);

            _jsonMetadata = jfactory.GetMetadata().ToList();

            var strategies = new IMetadataMapper[]
            {
                new ArrayMetadataMapper(), new DescriptorReferenceMetadataMapper(), new NameMatchingMetadataMapper()
            };

            var factory = new ResourceToResourceMetadataMappingFactory(
                _xmlMetadata.AsEnumerable(),
                _jsonMetadata.AsEnumerable(), strategies);

            _mappings = factory.GetMetadataMappings().ToArray();
        }
        public void Setup()
        {
            var ssbuilder = new SchemaSetFactory(new XsdStreamsRetriever(JsonMetadataTests.XmlMetadataConfiguration));
            var xfactory  = new XsdMetadataFactory(ssbuilder.GetSchemaSet());

            _xmlMetadata = xfactory.GetMetadata().ToList();

            var factory =
                new LookupToIdentityMetadataMappingFactory(_xmlMetadata, new NameMatchingMetadataMapper());

            _mappings = factory.GetMetadataMappings().ToArray();
        }
Esempio n. 4
0
        public static async Task <BulkLoadValidationResult> ValidateXmlFile(IConfiguration configuration,
                                                                            string[] unsupportedInterchanges)
        {
            var odsVersionInformation = await SetOdsEndpoints(configuration);

            var xsdConfiguration = BulkLoadClientConfiguration.Create(configuration);

            await LoadXsdFiles(xsdConfiguration, odsVersionInformation);

            var validationErrors = new BulkLoadValidationResult();
            var streamsRetriever = new XsdStreamsRetriever(xsdConfiguration);
            var factory          = new SchemaSetFactory(streamsRetriever);
            var schemaSet        = factory.GetSchemaSet();

            foreach (var fileToImport in GetFilesToImport(xsdConfiguration))
            {
                var xmlReaderSettings = new XmlReaderSettings
                {
                    ValidationType  = ValidationType.Schema,
                    Schemas         = schemaSet,
                    ValidationFlags = XmlSchemaValidationFlags.AllowXmlAttributes |
                                      XmlSchemaValidationFlags.ReportValidationWarnings |
                                      XmlSchemaValidationFlags.ProcessIdentityConstraints
                };

                xmlReaderSettings.ValidationEventHandler += (s, e) => { validationErrors.Add(e.Message); };

                await using var fileStream = new FileStream(fileToImport, FileMode.Open, FileAccess.Read);

                using (var reader = XmlReader.Create(fileStream, xmlReaderSettings))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element && unsupportedInterchanges.Any(
                                i => i.Equals(reader.Name, StringComparison.InvariantCultureIgnoreCase)))
                        {
                            validationErrors.Add($"Import of data for {reader.Name} is not supported");
                        }
                    }

                    reader.Close();
                }

                fileStream.Close();
            }

            return(validationErrors);
        }