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()); } }
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); } }
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); } }
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())); }
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())); } }