public async Task TestMethod1()
        {
            var spec = ZipSource.CreateValidationSource();

            var sd = await spec.FindStructureDefinitionForCoreTypeAsync("Patient");
            Assert.IsNotNull(sd);

            var sw = new Stopwatch();

            var te = ElementNode.FromElement(sd.ToTypedElement());

            sw.Start();
            ExpandoObject expando = null;
            for (int i=0; i < 1000; i++)
                expando = te.ToExpando();
            sw.Stop();
            Console.WriteLine($"ToExpando() took {sw.ElapsedMilliseconds / 1000.0} ms");

            ReadOnlyMemory<byte> memory = null;
            sw.Restart();
            for(int i=0; i < 1000; i++)
                memory = PrimitiveObjectFormatterCore.SerializeToMemory(expando);
            sw.Stop();
            Console.WriteLine($"Serializing an expando took {sw.ElapsedMilliseconds / 1000.0} ms");

            object result = null;
            sw.Restart();
            for (int i = 0; i < 1000; i++)
                result = PrimitiveObjectFormatterCore.Deserialize(memory);
            sw.Stop();
            Console.WriteLine($"Deserializing to an expando took {sw.ElapsedMilliseconds / 1000.0} ms");

            dynamic dyn = result;
            Assert.AreEqual("normative", dyn.extension[1].value.value);
        }
Exemplo n.º 2
0
        public void Setup()
        {
            var assembly      = Assembly.GetExecutingAssembly();
            var location      = new Uri(assembly.GetName().CodeBase);
            var directoryInfo = new FileInfo(location.AbsolutePath).Directory;

            Debug.Assert(directoryInfo != null, "directoryInfo != null");
            Debug.Assert(directoryInfo.FullName != null, "directoryInfo.FullName != null");

            var structureDefinitions  = directoryInfo.FullName + @"\Resources\StructureDefinitions";
            var includeSubDirectories = new DirectorySourceSettings {
                IncludeSubDirectories = true
            };
            var directorySource = new DirectorySource(structureDefinitions, includeSubDirectories);

            var cachedResolver = new CachedResolver(directorySource);
            var coreSource     = new CachedResolver(ZipSource.CreateValidationSource());
            var combinedSource = new MultiResolver(cachedResolver, coreSource);
            var settings       = new ValidationSettings
            {
                EnableXsdValidation = true,
                GenerateSnapshot    = true,
                Trace                    = true,
                ResourceResolver         = combinedSource,
                ResolveExteralReferences = true,
                SkipConstraintValidation = false
            };
            var validator = new Validator(settings);

            _profileValidator = new ProfileValidator(validator);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a default non-cached artifact resolver
 /// Default only searches in the executable directory files and the core zip.
 /// This non-cached resolver is primary for testing purposes.
 /// </summary>
 public static IResourceResolver CreateDefault()
 {
     return(new MultiResolver(new DirectorySource(new DirectorySourceSettings {
         IncludeSubDirectories = true
     }),
                              ZipSource.CreateValidationSource(), new WebResolver()));
 }
Exemplo n.º 4
0
        public void TestSourceCaching()
        {
            var src = new CachedResolver(new MultiResolver(ZipSource.CreateValidationSource(), new WebResolver()));

            Stopwatch sw1 = new Stopwatch();

            // Ensure looking up a failed endpoint repeatedly does not cost much time
            sw1.Start();
            src.ResolveByUri("http://some.none.existant.address.nl/fhir/StructureDefinition/bla");
            sw1.Stop();

            var sw2 = new Stopwatch();

            sw2.Start();
            src.ResolveByUri("http://some.none.existant.address.nl/fhir/StructureDefinition/bla");
            sw2.Stop();

            Debug.WriteLine("sw2 {0}, sw1 {1}", sw2.ElapsedMilliseconds, sw1.ElapsedMilliseconds);
            Assert.IsTrue(sw2.ElapsedMilliseconds <= sw1.ElapsedMilliseconds && sw2.ElapsedMilliseconds < 100);

            // Now try an existing artifact
            sw1.Restart();
            src.ResolveByUri("http://hl7.org/fhir/ValueSet/v2-0292");
            sw1.Stop();

            sw2.Restart();
            src.ResolveByUri("http://hl7.org/fhir/ValueSet/v2-0292");
            sw2.Stop();

            Assert.IsTrue(sw2.ElapsedMilliseconds < sw1.ElapsedMilliseconds && sw2.ElapsedMilliseconds < 100);
        }
Exemplo n.º 5
0
        int validate()
        {
            int returncode = 0;

            // Example from https://stackoverflow.com/questions/53399139/fhir-net-api-stu3-validating

            // https://www.devdays.com/wp-content/uploads/2019/02/DD18-US-Validation-in-NET-and-Java-Ewout-Kramer-James-Agnew-2018-06-19.pdf

            // https://blog.fire.ly/2016/10/27/validation-and-other-new-features-in-the-net-api-stack/


            // setup the resolver to use specification.zip, and a folder with custom profiles
            var source = new CachedResolver(new MultiResolver(
                                                new DirectorySource(@"C:\Users\dag\source\repos\FhirTool\SfmFhir\Profiles\"),
                                                ZipSource.CreateValidationSource()));

            // prepare the settings for the validator
            var ctx = new ValidationSettings()
            {
                ResourceResolver          = source,
                GenerateSnapshot          = true,
                Trace                     = false,
                EnableXsdValidation       = true,
                ResolveExternalReferences = false
            };

            var validator = new Validator(ctx);

            // validate the resource; optionally enter a custom profile url as 2nd parameter
            var result = validator.Validate(this);



            return(returncode);
        }
Exemplo n.º 6
0
        public void FullRoundtripOfAllExamplesJsonNavSdProvider()
        {
            var source = new CachedResolver(ZipSource.CreateValidationSource());

            FullRoundtripOfAllExamples("examples-json.zip", "FHIRRoundTripTestJson",
                                       "Roundtripping json->xml->json", usingPoco: false, provider: new StructureDefinitionSummaryProvider(source));
        }
        public SpecZipResourcesFixture()
        {
            var specSource = ZipSource.CreateValidationSource();

            Resources = specSource.FindAll <DataElement>().ToDictionary <DataElement, string>(sd => sd.Url);
            //By putting all the url's in a dictionary we can be sure there are no duplicates.
        }
Exemplo n.º 8
0
 /// <summary>
 /// Creates an offline non-cached artifact resolver
 /// Default only searches in the executable directory files and the core zip.
 /// </summary>
 public static IResourceResolver CreateOffline()
 {
     // Making requests to a WebArtifactSource is time consuming. So for performance we have an Offline Resolver.
     return(new MultiResolver(new DirectorySource(new DirectorySourceSettings {
         IncludeSubDirectories = true
     }),
                              ZipSource.CreateValidationSource()));
 }
        public void CannotCreateNestedSnapshotSource()
        {
            var orgSource    = ZipSource.CreateValidationSource();
            var cachedSource = new CachedResolver(orgSource);
            var src          = new SnapshotSource(cachedSource);

            // Verify that SnapshotSource ctor rejects SnapshotSource arguments
            Assert.ThrowsException <ArgumentException>(() => new SnapshotSource(src));
        }
Exemplo n.º 10
0
        public void TestZipSummary()
        {
            var source    = ZipSource.CreateValidationSource();
            var summaries = source.ListSummaries().ToList();

            Assert.IsNotNull(summaries);
            Assert.AreEqual(7155, summaries.FhirResources().Count());
            Assert.AreEqual(552, summaries.OfResourceType(ResourceType.StructureDefinition).Count());
            Assert.IsTrue(!summaries.Errors().Any());
        }
        static void InitCoreProfiles()
        {
            Console.WriteLine("Load FHIR core resource definitions...");

            var src = _coreSource = ZipSource.CreateValidationSource();

            _cachedCoreSource = new CachedResolver(src);
            var profiles = _coreProfiles = src.ListResourceUris(ResourceType.StructureDefinition).ToList();

            Console.WriteLine($"Found {profiles.Count} core definitions.");
        }
Exemplo n.º 12
0
        public void ListSummariesExcludingSubdirectories()
        {
            var zipfile = Path.Combine("TestData", "ResourcesInSubfolder.zip");
            var zip     = new ZipSource(zipfile, new DirectorySourceSettings()
            {
                IncludeSubDirectories = false
            });
            var summaries = zip.ListSummaries();

            Assert.IsNotNull(summaries, "Collection of summeries should not be null");
            Assert.AreEqual(1, summaries.Count(), "In the zipfile there is 1 resource in the root folder.");
        }
Exemplo n.º 13
0
        public void ListSummariesIncludingSubdirectories()
        {
            var zipfile = Path.Combine("TestData", "ResourcesInSubfolder.zip");
            var zip     = new ZipSource(zipfile, new DirectorySourceSettings()
            {
                IncludeSubDirectories = true
            });
            var summaries = zip.ListSummaries();

            Assert.IsNotNull(summaries, "Collection of summeries should not be null");
            Assert.AreEqual(20, summaries.Count(), "In the zipfile there are 20 resources distrubuted over several folders in the zipfile.");
        }
Exemplo n.º 14
0
        public void TestCanonicalUrlConflicts()
        {
            //const string srcFileName = "extension-definitions.xml";
            const string dupFileName = "diagnosticorder-reason-duplicate";
            const string url         = "http://hl7.org/fhir/StructureDefinition/diagnosticorder-reason";

            var za = ZipSource.CreateValidationSource();

            // Try to find a core extension
            var ext = za.ResolveByCanonicalUri(url);

            Assert.IsNotNull(ext);
            Assert.IsTrue(ext is StructureDefinition);

            // Save back to disk to create a conflicting duplicate
            var b = new Bundle();

            b.AddResourceEntry(ext, url);
            var xml       = new FhirXmlSerializer().SerializeToString(b);
            var filePath  = Path.Combine(DirectorySource.SpecificationDirectory, dupFileName) + ".xml";
            var filePath2 = Path.Combine(DirectorySource.SpecificationDirectory, dupFileName) + "2.xml";

            File.WriteAllText(filePath, xml);
            File.WriteAllText(filePath2, xml);

            bool conflictException = false;

            try
            {
                var fa  = new DirectorySource();
                var res = fa.ResolveByCanonicalUri(url);
            }
            catch (ResolvingConflictException ex)
            {
                Debug.WriteLine("{0}:\r\n{1}", ex.GetType().Name, ex.Message);
                Assert.IsNotNull(ex.Conflicts);
                Assert.AreEqual(1, ex.Conflicts.Length);
                var conflict = ex.Conflicts[0];
                Assert.AreEqual(url, conflict.Identifier);
                Assert.IsTrue(conflict.Origins.Contains(filePath));
                Assert.IsTrue(conflict.Origins.Contains(filePath2));
                conflictException = true;
            }
            finally
            {
                try { File.Delete(filePath); } catch { }
                File.Delete(filePath2);
            }
            Assert.IsTrue(conflictException);
        }
Exemplo n.º 15
0
        public ProfileValidator(IProvideProfilesForValidation profilesResolver, IOptions <ValidateOperationConfiguration> options)
        {
            EnsureArg.IsNotNull(profilesResolver, nameof(profilesResolver));
            EnsureArg.IsNotNull(options?.Value, nameof(options));

            try
            {
                _resolver = new MultiResolver(new CachedResolver(ZipSource.CreateValidationSource(), options.Value.CacheDurationInSeconds), profilesResolver);
            }
            catch (Exception)
            {
                // Something went wrong during profile loading, what should we do?
                throw;
            }
        }
        public void GetSomeArtifactsById()
        {
            var fa = ZipSource.CreateValidationSource();

            var vs = fa.ResolveByUri("http://hl7.org/fhir/ValueSet/v2-0292");

            Assert.IsNotNull(vs);
            Assert.IsTrue(vs is ValueSet);
            var ci = vs.Annotation <OriginInformation>();

            Assert.IsTrue(ci.Origin.EndsWith("v2-tables.xml"));

            vs = fa.ResolveByUri("http://hl7.org/fhir/ValueSet/administrative-gender");
            Assert.IsNotNull(vs);
            Assert.IsTrue(vs is ValueSet);

            vs = fa.ResolveByUri("http://hl7.org/fhir/ValueSet/location-status");
            Assert.IsNotNull(vs);
            Assert.IsTrue(vs is ValueSet);

            var rs = fa.ResolveByUri("http://hl7.org/fhir/StructureDefinition/Condition");

            Assert.IsNotNull(rs);
            Assert.IsTrue(rs is StructureDefinition);
            ci = rs.Annotation <OriginInformation>();
            Assert.IsTrue(ci.Origin.EndsWith("profiles-resources.xml"));

            rs = fa.ResolveByUri("http://hl7.org/fhir/StructureDefinition/ValueSet");
            Assert.IsNotNull(rs);
            Assert.IsTrue(rs is StructureDefinition);

            var dt = fa.ResolveByUri("http://hl7.org/fhir/StructureDefinition/Money");

            Assert.IsNotNull(dt);
            Assert.IsTrue(dt is StructureDefinition);

            // Try to find a core extension
            var ext = fa.ResolveByUri("http://hl7.org/fhir/StructureDefinition/diagnosticorder-reason");

            Assert.IsNotNull(ext);
            Assert.IsTrue(ext is StructureDefinition);

            // Try to find an additional US profile (they are distributed with the spec for now)
            var us = fa.ResolveByUri("http://hl7.org/fhir/StructureDefinition/uslab-dr");

            Assert.IsNotNull(us);
            Assert.IsTrue(us is StructureDefinition);
        }
Exemplo n.º 17
0
        public MainForm()
        {
            InitializeComponent();

            btnErrors.Tag   = "OFF";
            btnWarnings.Tag = "OFF";
            btnMessages.Tag = "OFF";

            btnError_Click(btnErrors, null);
            btnWarning_Click(btnWarnings, null);
            btnMessage_Click(btnMessages, null);
            // Create a resource resolver that searches for the core resources in 'specification.zip', which comes with the .NET FHIR Specification NuGet package
            // We create a source that takes its contents from a ZIP file (in this case the default 'specification.zip'). We decorate that source by encapsulating
            // it in a CachedResolver, which speeds up access by caching conformance resources once we got them from the large files in the ZIP.
            CoreSource = new CachedResolver(ZipSource.CreateValidationSource());
        }
Exemplo n.º 18
0
        public void TestSetupIsOnce()
        {
            var fa = ZipSource.CreateValidationSource();

            var sw = new Stopwatch();
            sw.Start();
            var vs = fa.ResolveByCanonicalUri("http://hl7.org/fhir/v2/vs/0292");
            sw.Stop();

            var sw2 = new Stopwatch();
            sw2.Start();
            var vs2 = fa.ResolveByCanonicalUri("http://hl7.org/fhir/v2/vs/0292");
            sw2.Stop();

            Assert.IsTrue(sw2.ElapsedMilliseconds < sw.ElapsedMilliseconds);
            Debug.WriteLine(String.Format("First time {0}, second time {1}", sw.ElapsedMilliseconds, sw2.ElapsedMilliseconds));
        }
Exemplo n.º 19
0
        public void Issue474StartdateIs0001_01_01()
        {
            var json = "{ \"resourceType\": \"Patient\", \"active\": true, \"contact\": [{\"organization\": {\"reference\": \"Organization/1\", \"display\": \"Walt Disney Corporation\" }, \"period\": { \"start\": \"0001-01-01\", \"end\": \"2018\" } } ],}";

            var ctx = new ValidationSettings()
            {
                ResourceResolver = ZipSource.CreateValidationSource(),
            };

            var validator = new Validator(ctx);

            var pat = new FhirJsonParser().Parse <Patient>(json);

            var report = validator.Validate(pat);

            Assert.IsTrue(report.Success);
        }
Exemplo n.º 20
0
        private FhirStructureDefinitions(String bundleDir)
        {
            this.bundleDir = bundleDir;
            if (Directory.Exists(bundleDir) == false)
            {
                Directory.CreateDirectory(bundleDir);
            }

            String specPath = Path.GetFullPath("specification.zip");

            if (File.Exists(specPath) == false)
            {
                throw new Exception($"Missing {specPath}");
            }
            this.source = new ZipSource(specPath);
            FhirStructureDefinitions.Self = this;
        }
Exemplo n.º 21
0
        public void TestZipSourceMask()
        {
            var zipFile = Path.Combine(Directory.GetCurrentDirectory(), "specification.zip");

            Assert.IsTrue(File.Exists(zipFile), "Error! specification.zip is not available.");
            var za = new ZipSource(zipFile);

            za.Mask = "profiles-types.xml";

            var artifacts = za.ListArtifactNames().ToArray();

            Assert.AreEqual(1, artifacts.Length);
            Assert.AreEqual("profiles-types.xml", artifacts[0]);

            var resourceIds = za.ListResourceUris(ResourceType.StructureDefinition).ToArray();

            Assert.IsNotNull(resourceIds);
            Assert.IsTrue(resourceIds.Length > 0);
            Assert.IsTrue(resourceIds.All(url => url.StartsWith("http://hl7.org/fhir/StructureDefinition/")));

            // + total number of known FHIR core types
            // - total number of known (concrete) resources
            // - 1 for abstract type Resource
            // - 1 for abstract type DomainResource
            // + 1 xhtml (not present as FhirCsType)
            // =======================================
            //   total number of known FHIR (complex & primitive) datatypes
            var coreDataTypes = ModelInfo.FhirCsTypeToString.Where(kvp => !ModelInfo.IsKnownResource(kvp.Key) &&
                                                                   kvp.Value != "Resource" &&
                                                                   kvp.Value != "DomainResource"
                                                                   )
                                .Select(kvp => kvp.Value).Concat(new[] { "xhtml" });
            var numCoreDataTypes = coreDataTypes.Count();

            Assert.AreEqual(resourceIds.Length, numCoreDataTypes);

            // Assert.IsTrue(resourceIds.All(url => ModelInfo.CanonicalUriForFhirCoreType));
            var coreTypeUris = coreDataTypes.Select(typeName => ModelInfo.CanonicalUriForFhirCoreType(typeName)).ToArray();

            // Boths arrays should contains same urls, possibly in different order
            Assert.AreEqual(coreTypeUris.Length, resourceIds.Length);
            Assert.IsTrue(coreTypeUris.All(url => resourceIds.Contains(url)));
            Assert.IsTrue(resourceIds.All(url => coreTypeUris.Contains(url)));
        }
Exemplo n.º 22
0
        public void TestLoadResourceFromZipSource()
        {
            // ZipSource extracts core ZIP archive to (temp) folder, then delegates to DirectorySource
            // i.e. artifact summaries are harvested from files on disk

            var source         = ZipSource.CreateValidationSource();
            var summaries      = source.ListSummaries();
            var patientUrl     = ModelInfo.CanonicalUriForFhirCoreType(FHIRDefinedType.Patient);
            var patientSummary = summaries.FindConformanceResources(patientUrl).FirstOrDefault();

            Assert.IsNotNull(patientSummary);
            Assert.AreEqual(ResourceType.StructureDefinition, patientSummary.ResourceType);
            Assert.AreEqual(patientUrl, patientSummary.GetConformanceCanonicalUrl());

            Assert.IsNotNull(patientSummary.Origin);
            var patientStructure = source.LoadBySummary <StructureDefinition>(patientSummary);

            Assert.IsNotNull(patientStructure);
        }
Exemplo n.º 23
0
        public void GetSomeBundledArtifacts()
        {
            var za = ZipSource.CreateValidationSource();

            using (var a = za.LoadArtifactByName("patient.sch"))
            {
                Assert.IsNotNull(a);
            }

            using (var a = za.LoadArtifactByName("v3-codesystems.xml"))
            {
                Assert.IsNotNull(a);
            }

            using (var a = za.LoadArtifactByName("patient.xsd"))
            {
                Assert.IsNotNull(a);
            }
        }
Exemplo n.º 24
0
        public void TestCacheInvalidation()
        {
            var src = new CachedResolver(new MultiResolver(ZipSource.CreateValidationSource()));

            CachedResolver.LoadResourceEventArgs    eventArgs = null;
            CachedResolver.LoadResourceEventHandler handler   = (sender, args) => { eventArgs = args; };
            src.Load += handler;

            // Verify that the Load event is fired on the initial load
            const string resourceUri = "http://hl7.org/fhir/ValueSet/v2-0292";
            var          resource    = src.ResolveByUri(resourceUri);

            Assert.IsNotNull(eventArgs);
            Assert.AreEqual(resourceUri, eventArgs.Url);
            Assert.AreEqual(resource, eventArgs.Resource);

            // Verify that the Load event is not fired on subsequent load
            eventArgs = null;
            resource  = src.ResolveByUri(resourceUri);
            Assert.IsNull(eventArgs);

            // Verify that we can remove the cache entry
            var result = src.InvalidateByUri(resourceUri);

            Assert.IsTrue(result);

            // Verify that the cache entry has been removed
            result = src.InvalidateByUri(resourceUri);
            Assert.IsFalse(result);

            // Verify that the Load event is fired again on the next load
            var resource2 = src.ResolveByUri(resourceUri);

            Assert.IsNotNull(eventArgs);
            Assert.AreEqual(resourceUri, eventArgs.Url);
            Assert.AreEqual(resource2, eventArgs.Resource);

            // Verify that the cache returned a new instance with exact same value
            Assert.AreNotEqual(resource2.GetHashCode(), resource.GetHashCode());
            Assert.IsTrue(resource.IsExactly(resource2));
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            var xml = "<Patient xmlns=\"http://hl7.org/fhir\"><identifier>" +
                      "<use value=\"official\" /></identifier></Patient>";
            MemoryStream memStream = new MemoryStream();

            byte[] data = Encoding.Default.GetBytes(xml);
            memStream.Write(data, 0, data.Length);
            memStream.Position = 0;
            XmlReader reader = XmlReader.Create(memStream);

            reader.Read();

            FhirXmlParsingSettings settings = new FhirXmlParsingSettings();

            ISourceNode patientNode = FhirXmlNode.Read(reader, settings);
            //IResourceResolver Resolver = new TestResourceResolver();
            IResourceResolver Resolver = ZipSource.CreateValidationSource();


            StructureDefinitionSummaryProvider Provider = new StructureDefinitionSummaryProvider(Resolver);



            ITypedElement patientRootElement = patientNode.ToTypedElement(Provider);

            var    r    = patientRootElement.Select("Patient.identifier.use");
            string test = (string)r.FirstOrDefault().Value;

            //ITypedElement activeElement = patientRootElement.Children("active").First();
            //Assert.AreEqual("boolean", activeElement.Type);

            //Assert.AreEqual("boolean", activeElement.Type);


            //var patientNode = FhirXmlNode.Parse(xml);
            //var use = patientNode.Children("identifier").Children("use").First();
            //Assert.AreEqual("official", use.Text);
            //Assert.AreEqual("Patient.identifier[0].use[0]", use.Location);
        }
Exemplo n.º 26
0
        public ValidationFixture()
        {
            var zip = ZipSource.CreateValidationSource();

            Resolver = new CachedResolver(
                new MultiResolver(
                    new TestProfileArtifactSource(),
                    new DirectorySource(@"TestData\validation"),
                    zip
                    ));

            var ctx = new ValidationSettings()
            {
                ResourceResolver    = Resolver,
                GenerateSnapshot    = true,
                EnableXsdValidation = true,
                Trace = false,
                ResolveExteralReferences = true
            };

            Validator = new Validator(ctx);
        }
Exemplo n.º 27
0
        public Validator GetValidator()
        {
            if (!IsValidationOn())
            {
                return(null);
            }

            var zipSource      = ZipSource.CreateValidationSource();
            var coreSource     = new CachedResolver(zipSource);
            var combinedSource = new MultiResolver(GetResourceResolver(), coreSource);
            var settings       = new ValidationSettings
            {
                EnableXsdValidation = true,
                GenerateSnapshot    = true,
                Trace                    = true,
                ResourceResolver         = combinedSource,
                ResolveExteralReferences = true,
                SkipConstraintValidation = false
            };

            return(new Validator(settings));
        }
Exemplo n.º 28
0
        public ProfileValidator(bool validateXsd, bool showTrace, bool reloadValidator, string profileFolder)
        {
            if (_validator != null && !reloadValidator)
            {
                return;
            }
            var coreSource     = new CachedResolver(ZipSource.CreateValidationSource());
            var cachedResolver = new CachedResolver(new DirectorySource(profileFolder, new DirectorySourceSettings {
                IncludeSubDirectories = true
            }));
            var combinedSource = new MultiResolver(cachedResolver, coreSource);
            var settings       = new ValidationSettings
            {
                EnableXsdValidation = validateXsd,
                GenerateSnapshot    = true,
                Trace                    = showTrace,
                ResourceResolver         = combinedSource,
                ResolveExteralReferences = true,
                SkipConstraintValidation = false
            };

            _validator = new Validator(settings);
        }
        public static Validator GetValidator()
        {
            var structureDefinitions  = GetStructureDefinitionsPath();
            var includeSubDirectories = new DirectorySourceSettings {
                IncludeSubDirectories = true
            };
            var directorySource = new DirectorySource(structureDefinitions, includeSubDirectories);

            var cachedResolver = new CachedResolver(directorySource);
            var coreSource     = new CachedResolver(ZipSource.CreateValidationSource());
            var combinedSource = new MultiResolver(cachedResolver, coreSource);
            var settings       = new ValidationSettings
            {
                EnableXsdValidation = true,
                GenerateSnapshot    = true,
                Trace                     = true,
                ResourceResolver          = combinedSource,
                ResolveExternalReferences = true,
                SkipConstraintValidation  = false
            };
            var validator = new Validator(settings);

            return(validator);
        }
Exemplo n.º 30
0
 public static void SetupSource(TestContext t)
 {
     source = ZipSource.CreateValidationSource();
 }