コード例 #1
0
        /// <summary>
        /// Implementation of the reader logic when in state 'Operation'.
        /// </summary>
        /// <returns>The batch reader state after the read.</returns>
        protected override ODataBatchReaderState ReadAtOperationImplementation()
        {
            if (this.JsonLightInputContext.JsonReader.NodeType != JsonNodeType.StartObject)
            {
                // No more requests in the batch.
                return(HandleMessagesEnd());
            }

            // Load the message properties if there is no cached item for processing.
            if (this.messagePropertiesCache == null)
            {
                // Load the message details since operation is detected.
                this.messagePropertiesCache = ODataJsonLightBatchPayloadItemPropertiesCache.Create(this);
            }

            // Calculate and return next state with changeset state detection.
            return(DetectChangesetStates(this.messagePropertiesCache));
        }
コード例 #2
0
        /// <summary>
        /// Implementation of the reader logic when in state 'Start'.
        /// </summary>
        /// <returns>The batch reader state after the read.</returns>
        protected override ODataBatchReaderState ReadAtStartImplementation()
        {
            Debug.Assert(this.State == ODataBatchReaderState.Initial, "this.State == ODataBatchReaderState.Initial");
            if (mode == ReaderMode.NotDetected)
            {
                // The stream should be positioned at the beginning of the batch envelope.
                // Need to detect whether we are reading request or response. Stay in Initial state upon return.
                DetectReaderMode();
                return(ODataBatchReaderState.Initial);
            }
            else
            {
                // The stream should be positioned at the beginning of requests array.
                this.StartReadingBatchArray();

                Debug.Assert(this.messagePropertiesCache == null, "this.messagePropertiesCache == null");
                this.messagePropertiesCache = ODataJsonLightBatchPayloadItemPropertiesCache.Create(this);

                string currentGroup = (string)this.messagePropertiesCache.GetPropertyValue(
                    ODataJsonLightBatchPayloadItemPropertiesCache.PropertyNameAtomicityGroup);

                if (currentGroup == null)
                {
                    return(ODataBatchReaderState.Operation);
                }
                else
                {
                    HandleNewAtomicGroupStart(
                        (string)
                        this.messagePropertiesCache.GetPropertyValue(
                            ODataJsonLightBatchPayloadItemPropertiesCache.PropertyNameId),
                        currentGroup);
                    return(ODataBatchReaderState.ChangesetStart);
                }
            }
        }