/// <summary> /// Deserialize JSON into a FHIR Provenance#Agent /// </summary> public static void DeserializeJson(this Provenance.AgentComponent 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($"Provenance.AgentComponent >>> Provenance#Agent.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"Provenance.AgentComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Deserialize JSON into a FHIR Provenance#Agent /// </summary> public static void DeserializeJsonProperty(this Provenance.AgentComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "type": current.Type = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Type).DeserializeJson(ref reader, options); break; case "role": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"AgentComponent error reading 'role' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Role = new List <CodeableConcept>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.CodeableConcept v_Role = new Hl7.Fhir.Model.CodeableConcept(); v_Role.DeserializeJson(ref reader, options); current.Role.Add(v_Role); if (!reader.Read()) { throw new JsonException($"AgentComponent error reading 'role' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Role.Count == 0) { current.Role = null; } break; case "who": current.Who = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Who).DeserializeJson(ref reader, options); break; case "onBehalfOf": current.OnBehalfOf = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.OnBehalfOf).DeserializeJson(ref reader, options); break; // Complex: agent, Export: AgentComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
/// <summary> /// Serialize a FHIR Provenance#Agent into JSON /// </summary> public static void SerializeJson(this Provenance.AgentComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: Provenance#Agent, Export: AgentComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); if (current.Type != null) { writer.WritePropertyName("type"); current.Type.SerializeJson(writer, options); } if ((current.Role != null) && (current.Role.Count != 0)) { writer.WritePropertyName("role"); writer.WriteStartArray(); foreach (CodeableConcept val in current.Role) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } writer.WritePropertyName("who"); current.Who.SerializeJson(writer, options); if (current.OnBehalfOf != null) { writer.WritePropertyName("onBehalfOf"); current.OnBehalfOf.SerializeJson(writer, options); } if (includeStartObject) { writer.WriteEndObject(); } }