public sealed override T?Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options !!)
 {
Exemplo n.º 2
0
        /// <summary>
        /// Deserialize a JSON property
        /// </summary>
        public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "code":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                Code = new List <CodeableConcept>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.CodeableConcept objCode = new fhirCsR4.Models.CodeableConcept();
                    objCode.DeserializeJson(ref reader, options);
                    Code.Add(objCode);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (Code.Count == 0)
                {
                    Code = null;
                }

                break;

            case "stratum":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                Stratum = new List <MeasureReportGroupStratifierStratum>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.MeasureReportGroupStratifierStratum objStratum = new fhirCsR4.Models.MeasureReportGroupStratifierStratum();
                    objStratum.DeserializeJson(ref reader, options);
                    Stratum.Add(objStratum);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (Stratum.Count == 0)
                {
                    Stratum = null;
                }

                break;

            default:
                ((fhirCsR4.Models.BackboneElement) this).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deserialize a JSON property
        /// </summary>
        public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "category":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                Category = new List <CodeableConcept>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.CodeableConcept objCategory = new fhirCsR4.Models.CodeableConcept();
                    objCategory.DeserializeJson(ref reader, options);
                    Category.Add(objCategory);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (Category.Count == 0)
                {
                    Category = null;
                }

                break;

            case "encounter":
                Encounter = new fhirCsR4.Models.Reference();
                Encounter.DeserializeJson(ref reader, options);
                break;

            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                Identifier = new List <Identifier>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.Identifier objIdentifier = new fhirCsR4.Models.Identifier();
                    objIdentifier.DeserializeJson(ref reader, options);
                    Identifier.Add(objIdentifier);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (Identifier.Count == 0)
                {
                    Identifier = null;
                }

                break;

            case "managingOrganization":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                ManagingOrganization = new List <Reference>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.Reference objManagingOrganization = new fhirCsR4.Models.Reference();
                    objManagingOrganization.DeserializeJson(ref reader, options);
                    ManagingOrganization.Add(objManagingOrganization);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (ManagingOrganization.Count == 0)
                {
                    ManagingOrganization = null;
                }

                break;

            case "name":
                Name = reader.GetString();
                break;

            case "_name":
                _Name = new fhirCsR4.Models.Element();
                _Name.DeserializeJson(ref reader, options);
                break;

            case "note":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                Note = new List <Annotation>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.Annotation objNote = new fhirCsR4.Models.Annotation();
                    objNote.DeserializeJson(ref reader, options);
                    Note.Add(objNote);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (Note.Count == 0)
                {
                    Note = null;
                }

                break;

            case "participant":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                Participant = new List <CareTeamParticipant>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.CareTeamParticipant objParticipant = new fhirCsR4.Models.CareTeamParticipant();
                    objParticipant.DeserializeJson(ref reader, options);
                    Participant.Add(objParticipant);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (Participant.Count == 0)
                {
                    Participant = null;
                }

                break;

            case "period":
                Period = new fhirCsR4.Models.Period();
                Period.DeserializeJson(ref reader, options);
                break;

            case "reasonCode":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                ReasonCode = new List <CodeableConcept>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.CodeableConcept objReasonCode = new fhirCsR4.Models.CodeableConcept();
                    objReasonCode.DeserializeJson(ref reader, options);
                    ReasonCode.Add(objReasonCode);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (ReasonCode.Count == 0)
                {
                    ReasonCode = null;
                }

                break;

            case "reasonReference":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                ReasonReference = new List <Reference>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.Reference objReasonReference = new fhirCsR4.Models.Reference();
                    objReasonReference.DeserializeJson(ref reader, options);
                    ReasonReference.Add(objReasonReference);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (ReasonReference.Count == 0)
                {
                    ReasonReference = null;
                }

                break;

            case "status":
                Status = reader.GetString();
                break;

            case "_status":
                _Status = new fhirCsR4.Models.Element();
                _Status.DeserializeJson(ref reader, options);
                break;

            case "subject":
                Subject = new fhirCsR4.Models.Reference();
                Subject.DeserializeJson(ref reader, options);
                break;

            case "telecom":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                Telecom = new List <ContactPoint>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.ContactPoint objTelecom = new fhirCsR4.Models.ContactPoint();
                    objTelecom.DeserializeJson(ref reader, options);
                    Telecom.Add(objTelecom);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (Telecom.Count == 0)
                {
                    Telecom = null;
                }

                break;

            default:
                ((fhirCsR4.Models.DomainResource) this).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemplo n.º 4
0
        protected override Track ReadObjectContents(ref Utf8JsonReader reader, JsonSerializerOptions options)
        {
            IReadOnlyList <INameCredit>?artistCredit = null;
            Guid?      id        = null;
            TimeSpan?  length    = null;
            string?    number    = null;
            int?       position  = null;
            IRecording?recording = null;
            string?    title     = null;
            Dictionary <string, object?>?rest = null;

            while (reader.TokenType == JsonTokenType.PropertyName)
            {
                var prop = reader.GetPropertyName();
                try {
                    reader.Read();
                    switch (prop)
                    {
                    case "artist-credit":
                        artistCredit = reader.ReadList(NameCreditReader.Instance, options);
                        break;

                    case "id":
                        id = reader.GetGuid();
                        break;

                    case "length":
                        length = reader.GetOptionalTimeSpanFromMilliseconds();
                        break;

                    case "number":
                        number = reader.GetString();
                        break;

                    case "position":
                        position = reader.GetOptionalInt32();
                        break;

                    case "recording":
                        recording = reader.GetOptionalObject(RecordingReader.Instance, options);
                        break;

                    case "title":
                        title = reader.GetString();
                        break;

                    default:
                        rest ??= new Dictionary <string, object?>();
                        rest[prop] = reader.GetOptionalObject(options);
                        break;
                    }
                }
                catch (Exception e) {
                    throw new JsonException($"Failed to deserialize the '{prop}' property.", e);
                }
                reader.Read();
            }
            if (id == null)
            {
                throw new JsonException("Expected property 'id' not found or null.");
            }
            if (title == null)
            {
                throw new JsonException("Expected track title not found or null.");
            }
            return(new Track(id.Value, title)
            {
                ArtistCredit = artistCredit,
                Length = length,
                Number = number,
                Position = position,
                Recording = recording,
                UnhandledProperties = rest,
            });
        }
Exemplo n.º 5
0
        public override BoxplotAggregation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            if (reader.TokenType != JsonTokenType.StartObject)
            {
                throw new JsonException("Unexpected JSON detected.");
            }
            reader.Read();
            var aggName = reader.GetString();

            if (aggName != "boxplot")
            {
                throw new JsonException("Unexpected JSON detected.");
            }
            var agg = new BoxplotAggregation(aggName);

            while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
            {
                if (reader.TokenType == JsonTokenType.PropertyName)
                {
                    if (reader.ValueTextEquals("compression"))
                    {
                        var value = JsonSerializer.Deserialize <double?>(ref reader, options);
                        if (value is not null)
                        {
                            agg.Compression = value;
                        }

                        continue;
                    }

                    if (reader.ValueTextEquals("field"))
                    {
                        var value = JsonSerializer.Deserialize <Elastic.Clients.Elasticsearch.Field?>(ref reader, options);
                        if (value is not null)
                        {
                            agg.Field = value;
                        }

                        continue;
                    }

                    if (reader.ValueTextEquals("script"))
                    {
                        var value = JsonSerializer.Deserialize <ScriptBase?>(ref reader, options);
                        if (value is not null)
                        {
                            agg.Script = value;
                        }

                        continue;
                    }
                }
            }

            while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
            {
                if (reader.TokenType == JsonTokenType.PropertyName)
                {
                    if (reader.ValueTextEquals("meta"))
                    {
                        var value = JsonSerializer.Deserialize <Dictionary <string, object> >(ref reader, options);
                        if (value is not null)
                        {
                            agg.Meta = value;
                        }

                        continue;
                    }
                }
            }

            reader.Read();
            return(agg);
        }
Exemplo n.º 6
0
 public override AvroWriteSettings Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     using var document = JsonDocument.ParseValue(ref reader);
     return(DeserializeAvroWriteSettings(document.RootElement));
 }
Exemplo n.º 7
0
 public override PaymentStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     return((PaymentStatus)Enum.Parse(typeof(PaymentStatus), reader.GetString(), true));
 }
 public override ReadOnlyMemory <byte> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 => reader.GetBytesFromBase64();
 public override SalesforceMarketingCloudLinkedService Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     using var document = JsonDocument.ParseValue(ref reader);
     return(DeserializeSalesforceMarketingCloudLinkedService(document.RootElement));
 }
Exemplo n.º 10
0
 public override AcsChatParticipantAddedToThreadEventData Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     using var document = JsonDocument.ParseValue(ref reader);
     return(DeserializeAcsChatParticipantAddedToThreadEventData(document.RootElement));
 }
 public override TC Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     if (reader.TokenType == JsonTokenType.Null)
     {
         return(default !);
Exemplo n.º 12
0
 /// <summary>
 /// Extracts an array of an array of points from a Utf8JsonReader
 /// </summary>
 /// <param name="reader">A Utf8JsonReader positioned at the first number in the first array</param>
 public override void Process(ref Utf8JsonReader reader)
 {
     Points = reader.ReadPolygonOrMultiLineString();
 }
Exemplo n.º 13
0
 public override DatasetZipDeflateCompression Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     using var document = JsonDocument.ParseValue(ref reader);
     return(DeserializeDatasetZipDeflateCompression(document.RootElement));
 }
 /// <summary>
 /// This is used for MultiCall response resolution
 /// <returns>Type</returns>
 /// </summary>
 override public Response ReadResponse(ref Utf8JsonReader reader, JsonSerializerOptions options)
 {
     return(JsonSerializer.Deserialize <AttributeTemplateAttributeInsertResponse>(ref reader, options));
 }
Exemplo n.º 15
0
 public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     Debug.Assert(typeToConvert == typeof(DateTime));
     return(DateTime.Parse(reader.GetString()));
 }
Exemplo n.º 16
0
        public override ClientJoinDeniedEvent Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            JsonCommentHandling commentHandling = options.ReadCommentHandling;

            reader.SkipComments(commentHandling);
            reader.ExpectJsonToken(JsonTokenType.StartObject);

            bool readReason = false;

            Guid?  eventId                  = null;
            string?clientIdentifier         = null;
            ClientJoinDeniedCode?reasonCode = null;
            string?reason = null;

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.Comment)
                {
                    continue;
                }

                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    return(new ClientJoinDeniedEvent(
                               eventId: eventId ?? throw new JsonException($"Property {nameof(ClientJoinAcceptedEvent.EventId)} is not defined."),
                               clientIdentifier: clientIdentifier ?? throw new JsonException($"Property {nameof(ClientJoinAcceptedEvent.ClientIdentifier)} is not defined."),
                               reasonCode: reasonCode ?? throw new JsonException($"Property {nameof(ClientJoinAcceptedEvent.ClientIdentifier)} is not defined."),
                               reason: reason));
                }

                reader.ExpectJsonToken(JsonTokenType.PropertyName);
                string propertyName = reader.GetString();

                if (propertyName.Equals(nameof(ClientJoinDeniedEvent.EventId)))
                {
                    if (eventId.HasValue)
                    {
                        throw new JsonException("Property defined twice: " + propertyName);
                    }

                    reader.ReadSkippingComments(commentHandling);
                    reader.ExpectJsonToken(JsonTokenType.String);
                    eventId = reader.GetGuid();
                }
                else if (propertyName.Equals(nameof(ClientJoinDeniedEvent.ClientIdentifier)))
                {
                    if (!(clientIdentifier is null))
                    {
                        throw new JsonException("Property defined twice: " + propertyName);
                    }

                    reader.ReadSkippingComments(commentHandling);
                    reader.ExpectJsonToken(JsonTokenType.String);
                    clientIdentifier = reader.GetString();
                }
                else if (propertyName.Equals(nameof(ClientJoinDeniedEvent.ReasonCode)))
                {
                    if (reasonCode.HasValue)
                    {
                        throw new JsonException("Property defined twice: " + propertyName);
                    }

                    reader.ReadSkippingComments(commentHandling);
                    reader.ExpectJsonToken(JsonTokenType.Number);
                    reasonCode = (ClientJoinDeniedCode)reader.GetInt32();

                    if (!Enum.IsDefined(typeof(ClientJoinDeniedCode), reasonCode.Value))
                    {
                        throw new JsonException(reasonCode.Value + " is an invalid enum value of " + nameof(ClientJoinDeniedCode));
                    }
                }
                else if (propertyName.Equals(nameof(ClientJoinDeniedEvent.Reason)))
                {
                    if (readReason)
                    {
                        throw new JsonException("Property defined twice: " + propertyName);
                    }

                    readReason = true;

                    reader.ReadSkippingComments(commentHandling);
                    reason = reader.TokenType switch
                    {
                        JsonTokenType.String => reader.GetString(),
                        JsonTokenType.Null => null,
                        _ => throw new JsonException($"Expected Token Type String or Null. Actual: {reader.TokenType}")
                    };
                }
                else
                {
                    reader.Skip();
                }
            }

            throw new JsonException("Json input ended unexpectedly.");
        }
Exemplo n.º 17
0
        public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var value = reader.GetInt64();

            return(new TimeSpan(value * TicksPerMicroseconds));
        }
Exemplo n.º 18
0
 public override Dictionary <TKey, TValue> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
Exemplo n.º 19
0
 public override DataFlowDebugQueryResponse Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     using var document = JsonDocument.ParseValue(ref reader);
     return(DeserializeDataFlowDebugQueryResponse(document.RootElement));
 }
Exemplo n.º 20
0
        public override Version Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            if (reader.TokenType != JsonTokenType.String)
            {
                throw ThrowHelper.GetInvalidOperationException_ExpectedString(reader.TokenType);
            }

#if BUILDING_INBOX_LIBRARY
            bool isEscaped = reader._stringHasEscaping;

            int maxLength = isEscaped ? MaximumEscapedVersionLength : MaximumVersionLength;
            ReadOnlySpan <byte> source = stackalloc byte[0];
            if (reader.HasValueSequence)
            {
                if (!JsonHelpers.IsInRangeInclusive(reader.ValueSequence.Length, MinimumVersionLength, maxLength))
                {
                    throw ThrowHelper.GetFormatException(DataType.Version);
                }

                Span <byte> stackSpan = stackalloc byte[isEscaped ? MaximumEscapedVersionLength : MaximumVersionLength];
                reader.ValueSequence.CopyTo(stackSpan);
                source = stackSpan.Slice(0, (int)reader.ValueSequence.Length);
            }
            else
            {
                source = reader.ValueSpan;

                if (!JsonHelpers.IsInRangeInclusive(source.Length, MinimumVersionLength, maxLength))
                {
                    throw ThrowHelper.GetFormatException(DataType.Version);
                }
            }

            if (isEscaped)
            {
                int backslash = source.IndexOf(JsonConstants.BackSlash);
                Debug.Assert(backslash != -1);

                Span <byte> sourceUnescaped = stackalloc byte[MaximumEscapedVersionLength];

                JsonReaderHelper.Unescape(source, sourceUnescaped, backslash, out int written);
                Debug.Assert(written > 0);

                source = sourceUnescaped.Slice(0, written);
                Debug.Assert(!source.IsEmpty);
            }

            byte firstChar = source[0];
            byte lastChar  = source[source.Length - 1];
            if (!JsonHelpers.IsDigit(firstChar) || !JsonHelpers.IsDigit(lastChar))
            {
                // Since leading and trailing whitespaces are forbidden throughout System.Text.Json converters
                // we need to make sure that our input doesn't have them,
                // and if it has - we need to throw, to match behaviour of other converters
                // since Version.TryParse allows them and silently parses input to Version
                throw ThrowHelper.GetFormatException(DataType.Version);
            }

            Span <char> charBuffer   = stackalloc char[MaximumVersionLength];
            int         writtenChars = JsonReaderHelper.s_utf8Encoding.GetChars(source, charBuffer);
            if (Version.TryParse(charBuffer.Slice(0, writtenChars), out Version? result))
            {
                return(result);
            }
#else
            string?versionString = reader.GetString();
            if (!string.IsNullOrEmpty(versionString) && (!char.IsDigit(versionString[0]) || !char.IsDigit(versionString[versionString.Length - 1])))
            {
                // Since leading and trailing whitespaces are forbidden throughout System.Text.Json converters
                // we need to make sure that our input doesn't have them,
                // and if it has - we need to throw, to match behaviour of other converters
                // since Version.TryParse allows them and silently parses input to Version
                throw ThrowHelper.GetFormatException(DataType.Version);
            }
            if (Version.TryParse(versionString, out Version? result))
            {
                return(result);
            }
#endif
            ThrowHelper.ThrowJsonException();
            return(null);
        }
Exemplo n.º 21
0
 public override ActivitySpanId Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 22
0
 public override SyntaxToken Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     throw new NotImplementedException();
 }
 public override SparkJobProperties Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     using var document = JsonDocument.ParseValue(ref reader);
     return(DeserializeSparkJobProperties(document.RootElement));
 }
        public override string SanitizeTextBody(string contentType, string body)
        {
            if (contentType.Contains("json"))
            {
                try
                {
                    // Check for auth calls to readact any access tokens
                    var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(body).AsSpan(), true, new JsonReaderState());
                    if (JsonDocument.TryParseValue(ref reader, out JsonDocument doc) &&
                        doc.RootElement.GetProperty("token_type").GetString() == "Bearer")
                    {
                        // If we found an auth call, sanitize it
                        using (var stream = new System.IO.MemoryStream())
                        {
                            using (var writer = new Utf8JsonWriter(stream))
                            {
                                writer.WriteStartObject();
                                foreach (JsonProperty property in doc.RootElement.EnumerateObject())
                                {
                                    switch (doc.RootElement.GetProperty(property.Name).ValueKind)
                                    {
                                    case JsonValueKind.Null:
                                        writer.WriteNull(property.Name);
                                        break;

                                    case JsonValueKind.True:
                                        writer.WriteBoolean(property.Name, true);
                                        break;

                                    case JsonValueKind.False:
                                        writer.WriteBoolean(property.Name, false);
                                        break;

                                    case JsonValueKind.Number:
                                        writer.WriteNumber(property.Name, property.Value.GetDouble());
                                        break;

                                    case JsonValueKind.String:
                                        writer.WriteString(
                                            property.Name,
                                            property.Name == "access_token" ?
                                            SanitizeValue :
                                            property.Value.GetString());
                                        break;
                                        // Ignore nested objects and arrays...
                                    }
                                }
                                writer.WriteEndObject();
                            }
                            return(Encoding.UTF8.GetString(stream.ToArray()));
                        }
                    }
                }
                catch
                {
                }
            }
            else if (contentType.Contains("urlencoded"))
            {
                try
                {
                    // If it's been URL encoded, make sure it doesn't contain
                    // a client_secret
                    var builder = new UriBuilder()
                    {
                        Query = body
                    };
                    var query = new UriQueryParamsCollection(body);
                    if (query.ContainsKey("client_secret"))
                    {
                        query["client_secret"] = SanitizeValue;
                    }
                    return(query.ToString());
                }
                catch
                {
                }
            }

            // If anything goes wrong, don't sanitize
            return(body);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Deserialize a JSON property
        /// </summary>
        public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "date":
                Date = reader.GetString();
                break;

            case "_date":
                _Date = new fhirCsR4.Models.Element();
                _Date.DeserializeJson(ref reader, options);
                break;

            case "evaluatedResource":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                EvaluatedResource = new List <Reference>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.Reference objEvaluatedResource = new fhirCsR4.Models.Reference();
                    objEvaluatedResource.DeserializeJson(ref reader, options);
                    EvaluatedResource.Add(objEvaluatedResource);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (EvaluatedResource.Count == 0)
                {
                    EvaluatedResource = null;
                }

                break;

            case "group":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                Group = new List <MeasureReportGroup>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.MeasureReportGroup objGroup = new fhirCsR4.Models.MeasureReportGroup();
                    objGroup.DeserializeJson(ref reader, options);
                    Group.Add(objGroup);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (Group.Count == 0)
                {
                    Group = null;
                }

                break;

            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                Identifier = new List <Identifier>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.Identifier objIdentifier = new fhirCsR4.Models.Identifier();
                    objIdentifier.DeserializeJson(ref reader, options);
                    Identifier.Add(objIdentifier);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (Identifier.Count == 0)
                {
                    Identifier = null;
                }

                break;

            case "improvementNotation":
                ImprovementNotation = new fhirCsR4.Models.CodeableConcept();
                ImprovementNotation.DeserializeJson(ref reader, options);
                break;

            case "measure":
                Measure = reader.GetString();
                break;

            case "_measure":
                _Measure = new fhirCsR4.Models.Element();
                _Measure.DeserializeJson(ref reader, options);
                break;

            case "period":
                Period = new fhirCsR4.Models.Period();
                Period.DeserializeJson(ref reader, options);
                break;

            case "reporter":
                Reporter = new fhirCsR4.Models.Reference();
                Reporter.DeserializeJson(ref reader, options);
                break;

            case "status":
                Status = reader.GetString();
                break;

            case "_status":
                _Status = new fhirCsR4.Models.Element();
                _Status.DeserializeJson(ref reader, options);
                break;

            case "subject":
                Subject = new fhirCsR4.Models.Reference();
                Subject.DeserializeJson(ref reader, options);
                break;

            case "type":
                Type = reader.GetString();
                break;

            case "_type":
                _Type = new fhirCsR4.Models.Element();
                _Type.DeserializeJson(ref reader, options);
                break;

            default:
                ((fhirCsR4.Models.DomainResource) this).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
 public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     return(DateTimeOffset.FromUnixTimeMilliseconds(reader.GetInt64()).DateTime);
 }
Exemplo n.º 27
0
        /// <summary>
        /// Deserialize a JSON property
        /// </summary>
        public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "code":
                Code = new fhirCsR4.Models.CodeableConcept();
                Code.DeserializeJson(ref reader, options);
                break;

            case "measureScore":
                MeasureScore = new fhirCsR4.Models.Quantity();
                MeasureScore.DeserializeJson(ref reader, options);
                break;

            case "population":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                Population = new List <MeasureReportGroupPopulation>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.MeasureReportGroupPopulation objPopulation = new fhirCsR4.Models.MeasureReportGroupPopulation();
                    objPopulation.DeserializeJson(ref reader, options);
                    Population.Add(objPopulation);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (Population.Count == 0)
                {
                    Population = null;
                }

                break;

            case "stratifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException();
                }

                Stratifier = new List <MeasureReportGroupStratifier>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    fhirCsR4.Models.MeasureReportGroupStratifier objStratifier = new fhirCsR4.Models.MeasureReportGroupStratifier();
                    objStratifier.DeserializeJson(ref reader, options);
                    Stratifier.Add(objStratifier);

                    if (!reader.Read())
                    {
                        throw new JsonException();
                    }
                }

                if (Stratifier.Count == 0)
                {
                    Stratifier = null;
                }

                break;

            default:
                ((fhirCsR4.Models.BackboneElement) this).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemplo n.º 28
0
        /// <inheritdoc/>
        public override T Read(ref Utf8JsonReader reader, Type type, JsonSerializerOptions options)
        {
            reader.GetString();

            return(NeonHelper.JsonDeserialize <T>(reader.GetString()));
        }
Exemplo n.º 29
0
 public override EntityReference Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 {
     using var document = JsonDocument.ParseValue(ref reader);
     return(DeserializeEntityReference(document.RootElement));
 }
 /// <summary>
 /// This is used for MultiCall response resolution
 /// <returns>Type</returns>
 /// </summary>
 override public Response ReadResponse(ref Utf8JsonReader reader, JsonSerializerOptions options)
 {
     return(JsonSerializer.Deserialize <PriceGroupBusinessAccountUpdateAssignedResponse>(ref reader, options));
 }