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

            throw new JsonException($"MarketingStatus: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
コード例 #2
0
        /// <summary>
        /// Deserialize JSON into a FHIR MarketingStatus
        /// </summary>
        public static void DeserializeJsonProperty(this MarketingStatus current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "country":
                current.Country = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Country).DeserializeJson(ref reader, options);
                break;

            case "jurisdiction":
                current.Jurisdiction = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Jurisdiction).DeserializeJson(ref reader, options);
                break;

            case "status":
                current.Status = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Status).DeserializeJson(ref reader, options);
                break;

            case "dateRange":
                current.DateRange = new Hl7.Fhir.Model.Period();
                ((Hl7.Fhir.Model.Period)current.DateRange).DeserializeJson(ref reader, options);
                break;

            case "restoreDate":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.RestoreDateElement = new FhirDateTime();
                    reader.Skip();
                }
                else
                {
                    current.RestoreDateElement = new FhirDateTime(reader.GetString());
                }
                break;

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

            // Complex: MarketingStatus, Export: MarketingStatus, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneType)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
コード例 #3
0
        /// <summary>
        /// Serialize a FHIR MarketingStatus into JSON
        /// </summary>
        public static void SerializeJson(this MarketingStatus current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Complex: MarketingStatus, Export: MarketingStatus, Base: BackboneElement (BackboneType)
            ((Hl7.Fhir.Model.BackboneType)current).SerializeJson(writer, options, false);

            writer.WritePropertyName("country");
            current.Country.SerializeJson(writer, options);

            if (current.Jurisdiction != null)
            {
                writer.WritePropertyName("jurisdiction");
                current.Jurisdiction.SerializeJson(writer, options);
            }

            writer.WritePropertyName("status");
            current.Status.SerializeJson(writer, options);

            writer.WritePropertyName("dateRange");
            current.DateRange.SerializeJson(writer, options);

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

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