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

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

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

            case "direction":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.DirectionElement = new Code <Hl7.Fhir.Model.DataRequirement.SortDirection>();
                    reader.Skip();
                }
                else
                {
                    current.DirectionElement = new Code <Hl7.Fhir.Model.DataRequirement.SortDirection>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.DataRequirement.SortDirection>(reader.GetString()));
                }
                break;

            case "_direction":
                if (current.DirectionElement == null)
                {
                    current.DirectionElement = new Code <Hl7.Fhir.Model.DataRequirement.SortDirection>();
                }
                ((Hl7.Fhir.Model.Element)current.DirectionElement).DeserializeJson(ref reader, options);
                break;

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

            writer.WriteString("path", current.PathElement.Value);

            writer.WriteString("direction", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.DirectionElement.Value));

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