public void AddDir(String path, String searchPattern, VerifyDel verifyDel = null) { foreach (String filePath in Directory.GetFiles(path, searchPattern)) { this.AddResource(filePath, verifyDel); } foreach (String subDir in Directory.GetDirectories(path)) { this.AddDir(subDir, searchPattern, verifyDel); } }
public void AddResource(String path, VerifyDel verifyDel) { DomainResource domainResource; switch (Path.GetExtension(path).ToUpper(CultureInfo.InvariantCulture)) { case ".XML": { FhirXmlParser parser = new FhirXmlParser(); domainResource = parser.Parse <DomainResource>(File.ReadAllText(path)); break; } case ".JSON": { FhirJsonParser parser = new FhirJsonParser(); domainResource = parser.Parse <DomainResource>(File.ReadAllText(path)); break; } default: throw new Exception($"Unknown extension for serialized fhir resource '{path}'"); } if (verifyDel != null) { if (verifyDel(domainResource) == false) { return; } } ResourceMap.Node node = this.CreateMapNode(domainResource); if (node == null) { return; } this.nodes.Add(node.ResourceUrl, node); this.resources.Add(domainResource.GetUrl(), domainResource); }