/// <summary> /// Unpacks the zip-file and constructs a new FileArtifactSource on the unzipped directory /// </summary> /// <remarks>This is an expensive operations and should be run once. As well, it unpacks files on the /// file system and is not thread-safe.</remarks> private void prepare() { if (_prepared) return; if (!File.Exists(_zipPath)) throw new FileNotFoundException(String.Format("Cannot prepare ZipArtifactSource: file '{0}' was not found", _zipPath )); var zc = new ZipCacher(_zipPath, CACHE_KEY); _filesSource = new FileDirectoryArtifactSource(zc.GetContentDirectory(), includeSubdirectories: false); _prepared = true; }
/// <summary> /// Unpacks the zip-file and constructs a new FileArtifactSource on the unzipped directory /// </summary> /// <remarks>This is an expensive operations and should be run once. As well, it unpacks files on the /// file system and is not thread-safe.</remarks> private void prepare() { if (_prepared) { return; } if (!File.Exists(_zipPath)) { throw new FileNotFoundException(String.Format("Cannot prepare ZipArtifactSource: file '{0}' was not found", _zipPath)); } var zc = new ZipCacher(_zipPath, CACHE_KEY); _filesSource = new FileDirectoryArtifactSource(zc.GetContentDirectory(), includeSubdirectories: false); _prepared = true; }
public void GenerateNorwegianSnapshots() { var mySource = new FileDirectoryArtifactSource(@"C:\Git\helsenord.ig\Source\Chapter.3.Package", includeSubdirectories: false); var stdSource = ZipArtifactSource.CreateValidationSource(); var resolver = new ArtifactResolver(new MultiArtifactSource(mySource, stdSource)); var sources = new[] { "noHealthcareService", "noHealthcareServiceLocation", "noOrganization", "noPractitioner", "acronym" }; var generator = new SnapshotGenerator(resolver, markChanges: false); foreach (var source in sources) { var sd = resolver.GetStructureDefinition("http://hl7.no/fhir/StructureDefinition/" + source); Assert.IsNotNull(sd, "Cannot find SD " + sd.Url); generator.Generate(sd); File.WriteAllText(@"C:\Git\helsenord.ig\Source\Chapter.3.Package\structure." + source + ".xml", FhirSerializer.SerializeResourceToXml(sd)); } }
public void ReadsSubdirectories() { var testPath = prepareExampleDirectory(); var fa = new FileDirectoryArtifactSource(testPath, includeSubdirectories:true); var names = fa.ListArtifactNames(); Assert.AreEqual(5,names.Count()); Assert.IsTrue(names.Contains("TestPatient.json")); }
public void FileSourceSkipsExecutables() { var fa = new FileDirectoryArtifactSource(_testPath); Assert.IsFalse(fa.ListArtifactNames().Any(name => name.EndsWith(".dll"))); Assert.IsFalse(fa.ListArtifactNames().Any(name => name.EndsWith(".exe"))); }
public void UseFileArtifactSource() { var fa = new FileDirectoryArtifactSource(_testPath); fa.Mask = "*.xml|*.xsd"; var names = fa.ListArtifactNames(); Assert.AreEqual(3, names.Count()); Assert.IsTrue(names.Contains("extension-definitions.xml")); Assert.IsTrue(names.Contains("flag.xsd")); Assert.IsFalse(names.Contains("patient.sch")); using (var stream = fa.LoadArtifactByName("TestPatient.xml")) { var pat = FhirParser.ParseResource(FhirParser.XmlReaderFromStream(stream)); Assert.IsNotNull(pat); } var vs = fa.LoadConformanceResourceByUrl("http://hl7.org/fhir/StructureDefinition/iso21090-preferred") as StructureDefinition; Assert.IsNotNull(vs); var cis = fa.ListConformanceResources(); foreach (var ci in cis) Debug.WriteLine(ci.ToString()); }