예제 #1
0
        private static byte[] serializeBody <T>(T data, ResourceFormat format, Func <T, byte[]> xmlSerializer, Func <T, byte[]> jsonSerializer)
        {
            var isBundle = data is Bundle;

            if (format == ResourceFormat.Json)
            {
                return(jsonSerializer(data)); // FhirSerializer.SerializeBundleToJsonBytes(bundle);
            }
            else if (format == ResourceFormat.Xml)
            {
                return(xmlSerializer(data));   // FhirSerializer.SerializeBundleToXmlBytes(bundle);
            }
            else
            {
                throw new ArgumentException("Cannot encode a batch into format " + format.ToString());
            }
        }
예제 #2
0
        public void ConvertResources(string inputDir, string outputDir, ResourceFormat inputFormat, ResourceFormat outputFormat, FileVersion outputVersion = 0x0)
        {
            this.progressUpdate("Enumerating files ...", 0, 1);
            var paths = new List <string>();

            EnumerateFiles(paths, inputDir, inputDir, "." + inputFormat.ToString().ToLower());

            this.progressUpdate("Converting resources ...", 0, 1);
            for (var i = 0; i < paths.Count; i++)
            {
                var path    = paths[i];
                var inPath  = inputDir + "/" + path;
                var outPath = outputDir + "/" + Path.ChangeExtension(path, outputFormat.ToString().ToLower());

                FileManager.TryToCreateDirectory(outPath);

                this.progressUpdate("Converting: " + inPath, i, paths.Count);
                var resource = LoadResource(inPath, inputFormat);
                SaveResource(resource, outPath, outputFormat, outputVersion);
            }
        }
예제 #3
0
        public void ConvertResources(string inputDir, string outputDir, ResourceFormat inputFormat, ResourceFormat outputFormat, int outputVersion = -1)
        {
            this.progressUpdate("Enumerating files ...", 0, 1);
            var paths = new List <string>();

            EnumerateFiles(paths, inputDir, inputDir, "." + inputFormat.ToString().ToLower());

            this.progressUpdate("Converting resources ...", 0, 1);
            for (var i = 0; i < paths.Count; i++)
            {
                var path    = paths[i];
                var inPath  = inputDir + "/" + path;
                var outPath = outputDir + "/" + Path.ChangeExtension(path, outputFormat.ToString().ToLower());
                var dirName = Path.GetDirectoryName(outPath);
                if (!Directory.Exists(dirName))
                {
                    Directory.CreateDirectory(dirName);
                }

                this.progressUpdate("Converting: " + inPath, i, paths.Count);
                var resource = LoadResource(inPath, inputFormat);
                SaveResource(resource, outPath, outputFormat, outputVersion);
            }
        }
예제 #4
0
        public static void AssertResourceResponseConformsTo(FhirClient client, ResourceFormat format)
        {
            AssertValidResourceContentTypePresent(client);

            var type = client.LastResponseDetails.ContentType;
            if (ContentType.GetResourceFormatFromContentType(type) != format)
                TestResult.Fail(String.Format("{0} is not acceptable when expecting {1}", type, format.ToString()));
        }
예제 #5
0
        public static void AssertResourceResponseConformsTo(FhirClient client, ResourceFormat format)
        {
            AssertValidResourceContentTypePresent(client);

            var type = client.LastResponseDetails.ContentType;

            if (ContentType.GetResourceFormatFromContentType(type) != format)
            {
                TestResult.Fail(String.Format("{0} is not acceptable when expecting {1}", type, format.ToString()));
            }
        }