Пример #1
0
        /// <summary>
        /// Decode dataset from the provided json decoder using the provided <see cref="DataSetReaderDataType"/>.
        /// </summary>
        /// <param name="jsonDecoder">The json decoder that contains the json stream.</param>
        /// <param name="messagesCount">Number of Messages found in current jsonDecoder. If 0 then there is SingleDataSetMessage</param>
        /// <param name="messagesListName">The name of the Messages list</param>
        /// <param name="dataSetReader">The <see cref="DataSetReaderDataType"/> used to decode the data set.</param>
        public void DecodePossibleDataSetReader(JsonDecoder jsonDecoder, int messagesCount, string messagesListName, DataSetReaderDataType dataSetReader)
        {
            if (messagesCount == 0)
            {
                // check if there shall be a dataset header and decode it
                if (HasDataSetMessageHeader)
                {
                    DecodeDataSetMessageHeader(jsonDecoder);

                    // push into PayloadStructure if there was a dataset header
                    jsonDecoder.PushStructure(kFieldPayload);
                }

                DecodeErrorReason = ValidateMetadataVersion(dataSetReader?.DataSetMetaData?.ConfigurationVersion);
                if (IsMetadataMajorVersionChange)
                {
                    return;
                }
                // handle single dataset with no network message header & no dataset message header (the content of the payload)
                DataSet = DecodePayloadContent(jsonDecoder, dataSetReader);
            }
            else
            {
                for (int index = 0; index < messagesCount; index++)
                {
                    bool wasPush = jsonDecoder.PushArray(messagesListName, index);
                    if (wasPush)
                    {
                        // atempt decoding the DataSet fields
                        DecodePossibleDataSetReader(jsonDecoder, dataSetReader);

                        // redo jsonDecoder stack
                        jsonDecoder.Pop();

                        if (DataSet != null)
                        {
                            // the dataset was decoded
                            return;
                        }
                    }
                }
            }
        }