Example #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="inputContext">The input context to read the content from.</param>
        /// <param name="batchBoundary">The boundary string for the batch structure itself.</param>
        /// <param name="batchEncoding">The encoding to use to read from the batch stream.</param>
        /// <param name="synchronous">true if the reader is created for synchronous operation; false for asynchronous.</param>
        internal ODataBatchReader(ODataRawInputContext inputContext, string batchBoundary, Encoding batchEncoding, bool synchronous)
        {
            Debug.Assert(inputContext != null, "inputContext != null");
            Debug.Assert(!string.IsNullOrEmpty(batchBoundary), "!string.IsNullOrEmpty(batchBoundary)");

            this.inputContext                  = inputContext;
            this.container                     = inputContext.Container;
            this.synchronous                   = synchronous;
            this.payloadUriConverter           = new ODataBatchPayloadUriConverter(inputContext.PayloadUriConverter);
            this.batchStream                   = new ODataBatchReaderStream(inputContext, batchBoundary, batchEncoding);
            this.allowLegacyContentIdBehaviour = true;
        }
Example #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="rawInputContext">The input context to read the content from.</param>
        /// <param name="encoding">The encoding for the underlying stream.</param>
        internal ODataAsynchronousReader(ODataRawInputContext rawInputContext, Encoding encoding)
        {
            Debug.Assert(rawInputContext != null, "rawInputContext != null");

            // Currently we only support single-byte UTF8 in async reader.
            if (encoding != null)
            {
                ReaderValidationUtils.ValidateEncodingSupportedInAsync(encoding);
            }

            this.rawInputContext = rawInputContext;
            this.container       = rawInputContext.Container;
        }
Example #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="inputContext">The input context to read the content from.</param>
        /// <param name="batchBoundary">The boundary string for the batch structure itself.</param>
        /// <param name="batchEncoding">The encoding to use to read from the batch stream.</param>
        internal ODataBatchReaderStream(
            ODataRawInputContext inputContext,
            string batchBoundary,
            Encoding batchEncoding)
        {
            Debug.Assert(inputContext != null, "inputContext != null");
            Debug.Assert(!string.IsNullOrEmpty(batchBoundary), "!string.IsNullOrEmpty(batchBoundary)");

            this.inputContext  = inputContext;
            this.batchBoundary = batchBoundary;
            this.batchEncoding = batchEncoding;

            this.batchBuffer = new ODataBatchReaderStreamBuffer();

            // When we allocate a batch reader stream we will in almost all cases also call ReadLine
            // (to read the headers of the parts); so allocating it here.
            this.lineBuffer = new byte[LineBufferLength];

            this.mediaTypeResolver = ODataMediaTypeResolver.GetMediaTypeResolver(inputContext.Container);
        }