Exemplo n.º 1
0
        /// <summary>
        /// Deserialize JSON into a FHIR DiagnosticReport#Media
        /// </summary>
        public static void DeserializeJson(this DiagnosticReport.MediaComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options)
        {
            string propertyName;

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    return;
                }

                if (reader.TokenType == JsonTokenType.PropertyName)
                {
                    propertyName = reader.GetString();
                    if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug)
                    {
                        Console.WriteLine($"DiagnosticReport.MediaComponent >>> DiagnosticReport#Media.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"DiagnosticReport.MediaComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deserialize JSON into a FHIR DiagnosticReport#Media
        /// </summary>
        public static void DeserializeJsonProperty(this DiagnosticReport.MediaComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "comment":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.CommentElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.CommentElement = new FhirString(reader.GetString());
                }
                break;

            case "_comment":
                if (current.CommentElement == null)
                {
                    current.CommentElement = new FhirString();
                }
                ((Hl7.Fhir.Model.Element)current.CommentElement).DeserializeJson(ref reader, options);
                break;

            case "link":
                current.Link = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Link).DeserializeJson(ref reader, options);
                break;

            // Complex: media, Export: MediaComponent, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Serialize a FHIR DiagnosticReport#Media into JSON
        /// </summary>
        public static void SerializeJson(this DiagnosticReport.MediaComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: DiagnosticReport#Media, Export: MediaComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.CommentElement != null)
            {
                if (!string.IsNullOrEmpty(current.CommentElement.Value))
                {
                    writer.WriteString("comment", current.CommentElement.Value);
                }
                if (current.CommentElement.HasExtensions() || (!string.IsNullOrEmpty(current.CommentElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_comment", false, current.CommentElement.Extension, current.CommentElement.ElementId);
                }
            }

            writer.WritePropertyName("link");
            current.Link.SerializeJson(writer, options);

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }