コード例 #1
0
        /// <summary>
        /// Deserialize JSON into a FHIR MedicinalProductPharmaceutical#TargetSpecies
        /// </summary>
        public static void DeserializeJson(this MedicinalProductPharmaceutical.TargetSpeciesComponent 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($"MedicinalProductPharmaceutical.TargetSpeciesComponent >>> MedicinalProductPharmaceutical#TargetSpecies.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"MedicinalProductPharmaceutical.TargetSpeciesComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
コード例 #2
0
        /// <summary>
        /// Serialize a FHIR MedicinalProductPharmaceutical#TargetSpecies into JSON
        /// </summary>
        public static void SerializeJson(this MedicinalProductPharmaceutical.TargetSpeciesComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: MedicinalProductPharmaceutical#TargetSpecies, Export: TargetSpeciesComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WritePropertyName("code");
            current.Code.SerializeJson(writer, options);

            if ((current.WithdrawalPeriod != null) && (current.WithdrawalPeriod.Count != 0))
            {
                writer.WritePropertyName("withdrawalPeriod");
                writer.WriteStartArray();
                foreach (MedicinalProductPharmaceutical.WithdrawalPeriodComponent val in current.WithdrawalPeriod)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
コード例 #3
0
        /// <summary>
        /// Deserialize JSON into a FHIR MedicinalProductPharmaceutical#TargetSpecies
        /// </summary>
        public static void DeserializeJsonProperty(this MedicinalProductPharmaceutical.TargetSpeciesComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "code":
                current.Code = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Code).DeserializeJson(ref reader, options);
                break;

            case "withdrawalPeriod":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"TargetSpeciesComponent error reading 'withdrawalPeriod' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.WithdrawalPeriod = new List <MedicinalProductPharmaceutical.WithdrawalPeriodComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.MedicinalProductPharmaceutical.WithdrawalPeriodComponent v_WithdrawalPeriod = new Hl7.Fhir.Model.MedicinalProductPharmaceutical.WithdrawalPeriodComponent();
                    v_WithdrawalPeriod.DeserializeJson(ref reader, options);
                    current.WithdrawalPeriod.Add(v_WithdrawalPeriod);

                    if (!reader.Read())
                    {
                        throw new JsonException($"TargetSpeciesComponent error reading 'withdrawalPeriod' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.WithdrawalPeriod.Count == 0)
                {
                    current.WithdrawalPeriod = null;
                }
                break;

            // Complex: targetSpecies, Export: TargetSpeciesComponent, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }