Esempio n. 1
0
        public string Convert(string content, FhirMimeType fhirMimeType)
        {
            var baseFromObject = FromSerializer.Parse(content);
            var baseToObject   = _converter.Convert <Base, Base>(baseFromObject.Resource);

            return(ToSerializer.Serialize(baseToObject, fhirMimeType));
        }
Esempio n. 2
0
        public string Serialize(Base resource, FhirMimeType type = FhirMimeType.Json)
        {
            switch (Version)
            {
            case FhirVersion.R3:
                var settingsR3 = new SerializerSettings {
                    Pretty = true
                };
                return(type == FhirMimeType.Json
                        ? new R3Serialization.FhirJsonSerializer(settingsR3).SerializeToString(resource)
                        : new R3Serialization.FhirXmlSerializer(settingsR3).SerializeToString(resource));

            case FhirVersion.R4:
                var settingsR4 = new SerializerSettings {
                    Pretty = true
                };
                return(type == FhirMimeType.Json

                        ? new R4Serialization.FhirJsonSerializer(settingsR4).SerializeToString(resource)
                        : new R4Serialization.FhirXmlSerializer(settingsR4).SerializeToString(resource));

            default:
                return(default);
            }
        }
Esempio n. 3
0
        private string GetContentAs(string content, FhirMimeType mimeType)
        {
            var serializer = new SerializationWrapper(_arguments.FhirVersion);
            var resource   = serializer.Parse(content);

            return(serializer.Serialize(resource, mimeType));
        }
 public FhirRequestMessage(HttpMethod method, ResourceWrapper resource, FhirMimeType mimeType = FhirMimeType.Json)
 {
     _method    = method;
     _resource  = resource;
     _mimeType  = mimeType;
     _mediaType = mimeType == FhirMimeType.Json
         ? "application/fhir+json"
         : "application/fhir+xml";
     _serializer = new SerializationWrapper(resource.FhirVersion);
 }
        private string GetOutPath(string outPath, string fileName, FhirMimeType mimeType)
        {
            string path = outPath;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            var fileNameWithOutExtension = Path.GetFileNameWithoutExtension(fileName);

            path = Path.Combine(path, $"{fileNameWithOutExtension}.{GetFileExtension(mimeType)}");

            return(path);
        }
Esempio n. 6
0
 private string GetContentAsXml(string content, FhirMimeType currentMimeType)
 {
     return(currentMimeType == FhirMimeType.Xml ? content : GetContentAs(content, FhirMimeType.Xml));
 }
Esempio n. 7
0
 private string GetContentAsJson(string content, FhirMimeType currentMimeType)
 {
     return(currentMimeType == FhirMimeType.Json ? content : GetContentAs(content, FhirMimeType.Json));
 }
Esempio n. 8
0
        private string TransformJust(string content, FhirMimeType currentMimeType)
        {
            var jsonFile = GetContentAsJson(content, currentMimeType);

            return(_justTransformer.Transform(jsonFile));
        }
Esempio n. 9
0
        private string TransformXslt(string content, FhirMimeType currentMimeType)
        {
            var xmlFile = GetContentAsXml(content, currentMimeType);

            return(_xslTransformer.Transform(xmlFile));
        }
Esempio n. 10
0
 public string Serialize(ResourceWrapper resourceWrapper, FhirMimeType type = FhirMimeType.Json)
 {
     return(Serialize(resourceWrapper.Resource, type));
 }