Ejemplo n.º 1
0
        private static Resource getResourceFromScannedSource(ResourceStreamScanner.ResourceScanInformation info)
        {
            var    path = info.Origin;
            string artifactXml;

            // Note: no exception handling. If the expected bundled file cannot be
            // read, throw the original exception.
            using (var content = File.OpenRead(path))
            {
                if (content == null)
                {
                    throw new FileNotFoundException("Cannot find file " + path);
                }

                var scanner = new ResourceStreamScanner(content, path);
                var entry   = scanner.FindResourceByUri(info.ResourceUri);

                artifactXml = entry != null?entry.ToString() : null;
            }

            if (artifactXml != null)
            {
                var resultResource = new FhirXmlParser().Parse <Resource>(artifactXml);
                resultResource.AddAnnotation(new OriginInformation {
                    Origin = info.Origin
                });
                return(resultResource);
            }
            else
            {
                return(null);
            }
        }