コード例 #1
0
ファイル: ODataAtomFormat.cs プロジェクト: nickchal/pash
 internal override IEnumerable<ODataPayloadKind> DetectPayloadKind(IODataResponseMessage responseMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull<IODataResponseMessage>(responseMessage, "responseMessage");
     ExceptionUtils.CheckArgumentNotNull<ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     Stream messageStream = ((ODataMessage) responseMessage).GetStream();
     return this.DetectPayloadKindImplementation(messageStream, true, true, detectionInfo);
 }
コード例 #2
0
ファイル: ODataAtomFormat.cs プロジェクト: nickchal/pash
 private IEnumerable<ODataPayloadKind> DetectPayloadKindImplementation(Stream messageStream, bool readingResponse, bool synchronous, ODataPayloadKindDetectionInfo detectionInfo)
 {
     using (ODataAtomInputContext context = new ODataAtomInputContext(this, messageStream, detectionInfo.GetEncoding(), detectionInfo.MessageReaderSettings, ODataVersion.V3, readingResponse, synchronous, detectionInfo.Model, null))
     {
         return context.DetectPayloadKind(detectionInfo);
     }
 }
コード例 #3
0
        /// <summary>
        /// Detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="requestMessage">The request message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
        internal override IEnumerable<ODataPayloadKind> DetectPayloadKind(
            IODataRequestMessage requestMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(requestMessage, "requestMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            return DetectPayloadKindImplementation(detectionInfo.ContentType);
        }
コード例 #4
0
        /// <summary>
        /// Asynchronously detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="requestMessage">The request message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>A task that when completed returns the set of <see cref="ODataPayloadKind"/>s
        /// that are supported with the specified payload.</returns>
        internal override Task <IEnumerable <ODataPayloadKind> > DetectPayloadKindAsync(
            IODataRequestMessageAsync requestMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(requestMessage, "requestMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            return(TaskUtils.GetTaskForSynchronousOperation(() => DetectPayloadKindImplementation(detectionInfo.ContentType)));
        }
コード例 #5
0
        /// <summary>
        /// Detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="requestMessage">The request message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
        internal override IEnumerable <ODataPayloadKind> DetectPayloadKind(
            IODataRequestMessage requestMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(requestMessage, "requestMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            return(DetectPayloadKindImplementation(detectionInfo.ContentType));
        }
コード例 #6
0
        /// <summary>
        /// Detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="requestMessage">The request message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
        internal override IEnumerable<ODataPayloadKind> DetectPayloadKind(
            IODataRequestMessage requestMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(requestMessage, "requestMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            // Metadata is not supported in requests!
            return Enumerable.Empty<ODataPayloadKind>();
        }
コード例 #7
0
        /// <summary>
        /// Detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="requestMessage">The request message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
        internal override IEnumerable <ODataPayloadKind> DetectPayloadKind(
            IODataRequestMessage requestMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(requestMessage, "requestMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            // Metadata is not supported in requests!
            return(Enumerable.Empty <ODataPayloadKind>());
        }
コード例 #8
0
        /// <summary>
        /// Detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="responseMessage">The response message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
        internal override IEnumerable<ODataPayloadKind> DetectPayloadKind(
            IODataResponseMessage responseMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(responseMessage, "responseMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            Stream messageStream = ((ODataMessage)responseMessage).GetStream();
            return DetectPayloadKindImplementation(messageStream, detectionInfo);
        }
コード例 #9
0
        /// <summary>
        /// Detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="responseMessage">The response message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
        internal override IEnumerable <ODataPayloadKind> DetectPayloadKind(
            IODataResponseMessage responseMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(responseMessage, "responseMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            Stream messageStream = ((ODataMessage)responseMessage).GetStream();

            return(DetectPayloadKindImplementation(messageStream, detectionInfo));
        }
コード例 #10
0
        /// <summary>
        /// Asynchronously detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="responseMessage">The response message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>A task that when completed returns the set of <see cref="ODataPayloadKind"/>s
        /// that are supported with the specified payload.</returns>
        internal override Task <IEnumerable <ODataPayloadKind> > DetectPayloadKindAsync(
            IODataResponseMessageAsync responseMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(responseMessage, "responseMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            // NOTE: After getting the message stream we already (asynchronously) buffered the whole stream in memory (in the AsyncBufferedStream).
            //       Until we get Task-based async stream APIs and retire the AsyncBufferedStream, we call the synchronous method on the buffered stream.
            return(((ODataMessage)responseMessage).GetStreamAsync()
                   .FollowOnSuccessWith(streamTask => DetectPayloadKindImplementation(streamTask.Result, detectionInfo)));
        }
コード例 #11
0
        public IEnumerable <ODataPayloadKindDetectionResult> DetectPayloadKind()
        {
            IEnumerable <ODataPayloadKindDetectionResult> enumerable;
            MediaType type;

            if (this.settings.ReaderBehavior.ApiBehaviorKind == ODataBehaviorKind.WcfDataServicesServer)
            {
                throw new ODataException(Microsoft.Data.OData.Strings.ODataMessageReader_PayloadKindDetectionInServerMode);
            }
            if (this.TryGetSinglePayloadKindResultFromContentType(out enumerable, out type))
            {
                return(enumerable);
            }
            List <ODataPayloadKindDetectionResult> list = new List <ODataPayloadKindDetectionResult>();

            try
            {
                foreach (IGrouping <ODataFormat, ODataPayloadKindDetectionResult> grouping in from kvp in enumerable group kvp by kvp.Format)
                {
                    ODataPayloadKindDetectionInfo  detectionInfo = new ODataPayloadKindDetectionInfo(type, this.settings, this.model, from pkg in grouping select pkg.PayloadKind);
                    IEnumerable <ODataPayloadKind> enumerable3   = this.readingResponse ? grouping.Key.DetectPayloadKind((IODataResponseMessage)this.message, detectionInfo) : grouping.Key.DetectPayloadKind((IODataRequestMessage)this.message, detectionInfo);
                    if (enumerable3 != null)
                    {
                        using (IEnumerator <ODataPayloadKind> enumerator2 = enumerable3.GetEnumerator())
                        {
                            Func <ODataPayloadKindDetectionResult, bool> predicate = null;
                            ODataPayloadKind kind;
                            while (enumerator2.MoveNext())
                            {
                                kind = enumerator2.Current;
                                if (predicate == null)
                                {
                                    predicate = pk => pk.PayloadKind == kind;
                                }
                                if (enumerable.Any <ODataPayloadKindDetectionResult>(predicate))
                                {
                                    list.Add(new ODataPayloadKindDetectionResult(kind, grouping.Key));
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                this.message.UseBufferingReadStream = false;
                this.message.BufferingReadStream.StopBuffering();
            }
            list.Sort(new Comparison <ODataPayloadKindDetectionResult>(this.ComparePayloadKindDetectionResult));
            return(list);
        }
コード例 #12
0
ファイル: ODataMetadataFormat.cs プロジェクト: nickchal/pash
 private static IEnumerable<ODataPayloadKind> DetectPayloadKindImplementation(Stream messageStream, ODataPayloadKindDetectionInfo detectionInfo)
 {
     try
     {
         using (XmlReader reader = ODataAtomReaderUtils.CreateXmlReader(messageStream, detectionInfo.GetEncoding(), detectionInfo.MessageReaderSettings))
         {
             string str;
             if (((reader.TryReadToNextElement() && (string.CompareOrdinal("Edmx", reader.LocalName) == 0)) && ((str = reader.NamespaceURI) != null)) && (((str == "http://schemas.microsoft.com/ado/2007/06/edmx") || (str == "http://schemas.microsoft.com/ado/2008/10/edmx")) || (str == "http://schemas.microsoft.com/ado/2009/11/edmx")))
             {
                 return new ODataPayloadKind[] { ODataPayloadKind.MetadataDocument };
             }
         }
     }
     catch (XmlException)
     {
     }
     return Enumerable.Empty<ODataPayloadKind>();
 }
コード例 #13
0
        private IEnumerable <Task> GetPayloadKindDetectionTasks(MediaType contentType, IEnumerable <ODataPayloadKindDetectionResult> payloadKindsFromContentType, List <ODataPayloadKindDetectionResult> detectionResults)
        {
            IEnumerable <IGrouping <ODataFormat, ODataPayloadKindDetectionResult> > iteratorVariable0 = from kvp in payloadKindsFromContentType group kvp by kvp.Format;

            using (IEnumerator <IGrouping <ODataFormat, ODataPayloadKindDetectionResult> > iteratorVariable6 = iteratorVariable0.GetEnumerator())
            {
                Action <Task <IEnumerable <ODataPayloadKind> > >         operation = null;
                IGrouping <ODataFormat, ODataPayloadKindDetectionResult> payloadKindGroup;
                while (iteratorVariable6.MoveNext())
                {
                    payloadKindGroup = iteratorVariable6.Current;
                    ODataPayloadKindDetectionInfo          detectionInfo  = new ODataPayloadKindDetectionInfo(contentType, this.settings, this.model, from pkg in payloadKindGroup select pkg.PayloadKind);
                    Task <IEnumerable <ODataPayloadKind> > antecedentTask = this.readingResponse ? payloadKindGroup.Key.DetectPayloadKindAsync((IODataResponseMessageAsync)this.message, detectionInfo) : payloadKindGroup.Key.DetectPayloadKindAsync((IODataRequestMessageAsync)this.message, detectionInfo);
                    if (operation == null)
                    {
                        operation = delegate(Task <IEnumerable <ODataPayloadKind> > t) {
                            IEnumerable <ODataPayloadKind> result = t.Result;
                            if (result != null)
                            {
                                using (IEnumerator <ODataPayloadKind> enumerator = result.GetEnumerator())
                                {
                                    Func <ODataPayloadKindDetectionResult, bool> predicate = null;
                                    while (enumerator.MoveNext())
                                    {
                                        ODataPayloadKind kind = enumerator.Current;
                                        if (predicate == null)
                                        {
                                            predicate = pk => pk.PayloadKind == kind;
                                        }
                                        if (payloadKindsFromContentType.Any <ODataPayloadKindDetectionResult>(predicate))
                                        {
                                            detectionResults.Add(new ODataPayloadKindDetectionResult(kind, payloadKindGroup.Key));
                                        }
                                    }
                                }
                            }
                        };
                    }
                    yield return(antecedentTask.FollowOnSuccessWith <IEnumerable <ODataPayloadKind> >(operation));
                }
            }
        }
コード例 #14
0
 internal IEnumerable<ODataPayloadKind> DetectPayloadKind(ODataPayloadKindDetectionInfo detectionInfo)
 {
     ODataAtomPayloadKindDetectionDeserializer deserializer = new ODataAtomPayloadKindDetectionDeserializer(this);
     return deserializer.DetectPayloadKind(detectionInfo);
 }
コード例 #15
0
 /// <summary>
 /// Asynchronously detects the payload kinds supported by this format for the specified message payload.
 /// </summary>
 /// <param name="requestMessage">The request message with the payload stream.</param>
 /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
 /// <returns>A task that when completed returns the set of <see cref="ODataPayloadKind"/>s
 /// that are supported with the specified payload.</returns>
 internal abstract Task <IEnumerable <ODataPayloadKind> > DetectPayloadKindAsync(IODataRequestMessageAsync requestMessage, ODataPayloadKindDetectionInfo detectionInfo);
コード例 #16
0
ファイル: ODataFormat.cs プロジェクト: smasonuk/odata-sparql
 /// <summary>
 /// Detects the payload kinds supported by this format for the specified message payload.
 /// </summary>
 /// <param name="responseMessage">The response message with the payload stream.</param>
 /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
 /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
 internal abstract IEnumerable<ODataPayloadKind> DetectPayloadKind(IODataResponseMessage responseMessage, ODataPayloadKindDetectionInfo detectionInfo);
コード例 #17
0
ファイル: ODataFormat.cs プロジェクト: smasonuk/odata-sparql
 /// <summary>
 /// Asynchronously detects the payload kinds supported by this format for the specified message payload.
 /// </summary>
 /// <param name="requestMessage">The request message with the payload stream.</param>
 /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
 /// <returns>A task that when completed returns the set of <see cref="ODataPayloadKind"/>s 
 /// that are supported with the specified payload.</returns>
 internal abstract Task<IEnumerable<ODataPayloadKind>> DetectPayloadKindAsync(IODataRequestMessageAsync requestMessage, ODataPayloadKindDetectionInfo detectionInfo);
コード例 #18
0
        /// <summary>
        /// Asynchronously detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="responseMessage">The response message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>A task that when completed returns the set of <see cref="ODataPayloadKind"/>s 
        /// that are supported with the specified payload.</returns>
        internal override Task<IEnumerable<ODataPayloadKind>> DetectPayloadKindAsync(
            IODataResponseMessageAsync responseMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(responseMessage, "responseMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            // NOTE: After getting the message stream we already (asynchronously) buffered the whole stream in memory (in the AsyncBufferedStream).
            //       Until we get Task-based async stream APIs and retire the AsyncBufferedStream, we call the synchronous method on the buffered stream.
            return ((ODataMessage)responseMessage).GetStreamAsync()
                .FollowOnSuccessWith(streamTask => DetectPayloadKindImplementation(streamTask.Result, detectionInfo));
        }
コード例 #19
0
ファイル: ODataAtomFormat.cs プロジェクト: nickchal/pash
 internal override Task<IEnumerable<ODataPayloadKind>> DetectPayloadKindAsync(IODataResponseMessageAsync responseMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull<IODataResponseMessageAsync>(responseMessage, "responseMessage");
     ExceptionUtils.CheckArgumentNotNull<ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     return ((ODataMessage) responseMessage).GetStreamAsync().FollowOnSuccessWith<Stream, IEnumerable<ODataPayloadKind>>(streamTask => this.DetectPayloadKindImplementation(streamTask.Result, true, false, detectionInfo));
 }
コード例 #20
0
 internal override Task <IEnumerable <ODataPayloadKind> > DetectPayloadKindAsync(IODataResponseMessageAsync responseMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull <IODataResponseMessageAsync>(responseMessage, "responseMessage");
     ExceptionUtils.CheckArgumentNotNull <ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     return(TaskUtils.GetTaskForSynchronousOperation <IEnumerable <ODataPayloadKind> >(() => DetectPayloadKindImplementation(detectionInfo.ContentType)));
 }
コード例 #21
0
 /// <summary>
 /// Detects the payload kinds supported by this format for the specified message payload.
 /// </summary>
 /// <param name="responseMessage">The response message with the payload stream.</param>
 /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
 /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
 internal abstract IEnumerable <ODataPayloadKind> DetectPayloadKind(IODataResponseMessage responseMessage, ODataPayloadKindDetectionInfo detectionInfo);
コード例 #22
0
        /// <summary>
        /// Asynchronously detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="requestMessage">The request message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>A task that when completed returns the set of <see cref="ODataPayloadKind"/>s 
        /// that are supported with the specified payload.</returns>
        internal override Task<IEnumerable<ODataPayloadKind>> DetectPayloadKindAsync(
            IODataRequestMessageAsync requestMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(requestMessage, "requestMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            return TaskUtils.GetTaskForSynchronousOperation(() => DetectPayloadKindImplementation(detectionInfo.ContentType));
        }
コード例 #23
0
ファイル: ODataBatchFormat.cs プロジェクト: nickchal/pash
 internal override IEnumerable<ODataPayloadKind> DetectPayloadKind(IODataResponseMessage responseMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull<IODataResponseMessage>(responseMessage, "responseMessage");
     ExceptionUtils.CheckArgumentNotNull<ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     return DetectPayloadKindImplementation(detectionInfo.ContentType);
 }
コード例 #24
0
 internal override Task <IEnumerable <ODataPayloadKind> > DetectPayloadKindAsync(IODataRequestMessageAsync requestMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull <IODataRequestMessageAsync>(requestMessage, "requestMessage");
     ExceptionUtils.CheckArgumentNotNull <ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     return(TaskUtils.GetCompletedTask <IEnumerable <ODataPayloadKind> >(Enumerable.Empty <ODataPayloadKind>()));
 }
コード例 #25
0
 internal override IEnumerable <ODataPayloadKind> DetectPayloadKind(IODataRequestMessage requestMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull <IODataRequestMessage>(requestMessage, "requestMessage");
     ExceptionUtils.CheckArgumentNotNull <ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     return(Enumerable.Empty <ODataPayloadKind>());
 }
コード例 #26
0
 internal IEnumerable<ODataPayloadKind> DetectPayloadKind(ODataPayloadKindDetectionInfo detectionInfo)
 {
     base.XmlReader.DisableInStreamErrorDetection = true;
     try
     {
         if (base.XmlReader.TryReadToNextElement())
         {
             if (string.CompareOrdinal("http://www.w3.org/2005/Atom", base.XmlReader.NamespaceURI) == 0)
             {
                 if (string.CompareOrdinal("entry", base.XmlReader.LocalName) == 0)
                 {
                     return new ODataPayloadKind[] { ODataPayloadKind.Entry };
                 }
                 if (base.ReadingResponse && (string.CompareOrdinal("feed", base.XmlReader.LocalName) == 0))
                 {
                     return new ODataPayloadKind[1];
                 }
             }
             else
             {
                 if (string.CompareOrdinal("http://schemas.microsoft.com/ado/2007/08/dataservices", base.XmlReader.NamespaceURI) == 0)
                 {
                     IEnumerable<ODataPayloadKind> possiblePayloadKinds = detectionInfo.PossiblePayloadKinds;
                     IEnumerable<ODataPayloadKind> first = (possiblePayloadKinds.Contains<ODataPayloadKind>(ODataPayloadKind.Property) || possiblePayloadKinds.Contains<ODataPayloadKind>(ODataPayloadKind.Collection)) ? this.DetectPropertyOrCollectionPayloadKind() : Enumerable.Empty<ODataPayloadKind>();
                     if (string.CompareOrdinal("uri", base.XmlReader.LocalName) == 0)
                     {
                         first = first.Concat<ODataPayloadKind>(new ODataPayloadKind[] { ODataPayloadKind.EntityReferenceLink });
                     }
                     if (base.ReadingResponse && (string.CompareOrdinal("links", base.XmlReader.LocalName) == 0))
                     {
                         first = first.Concat<ODataPayloadKind>(new ODataPayloadKind[] { ODataPayloadKind.EntityReferenceLinks });
                     }
                     return first;
                 }
                 if (string.CompareOrdinal("http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", base.XmlReader.NamespaceURI) == 0)
                 {
                     if (base.ReadingResponse && (string.CompareOrdinal("error", base.XmlReader.LocalName) == 0))
                     {
                         return new ODataPayloadKind[] { ODataPayloadKind.Error };
                     }
                     if (string.CompareOrdinal("uri", base.XmlReader.LocalName) == 0)
                     {
                         return new ODataPayloadKind[] { ODataPayloadKind.EntityReferenceLink };
                     }
                 }
                 else if (((string.CompareOrdinal("http://www.w3.org/2007/app", base.XmlReader.NamespaceURI) == 0) && base.ReadingResponse) && (string.CompareOrdinal("service", base.XmlReader.LocalName) == 0))
                 {
                     return new ODataPayloadKind[] { ODataPayloadKind.ServiceDocument };
                 }
             }
         }
     }
     catch (XmlException)
     {
     }
     finally
     {
         base.XmlReader.DisableInStreamErrorDetection = false;
     }
     return Enumerable.Empty<ODataPayloadKind>();
 }
コード例 #27
0
        /// <summary>
        /// Detects the payload kind(s) of the payload.
        /// </summary>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>An enumerable of zero or more payload kinds depending on what payload kinds were detected.</returns>
        internal IEnumerable<ODataPayloadKind> DetectPayloadKind(ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(detectionInfo != null, "detectionInfo != null");

            ODataAtomPayloadKindDetectionDeserializer payloadKindDetectionDeserializer = new ODataAtomPayloadKindDetectionDeserializer(this);
            return payloadKindDetectionDeserializer.DetectPayloadKind(detectionInfo);
        }
コード例 #28
0
 internal override IEnumerable <ODataPayloadKind> DetectPayloadKind(IODataResponseMessage responseMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull <IODataResponseMessage>(responseMessage, "responseMessage");
     ExceptionUtils.CheckArgumentNotNull <ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     return(DetectPayloadKindImplementation(detectionInfo.ContentType));
 }
コード例 #29
0
ファイル: ODataMetadataFormat.cs プロジェクト: nickchal/pash
 internal override IEnumerable<ODataPayloadKind> DetectPayloadKind(IODataRequestMessage requestMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull<IODataRequestMessage>(requestMessage, "requestMessage");
     ExceptionUtils.CheckArgumentNotNull<ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     return Enumerable.Empty<ODataPayloadKind>();
 }
コード例 #30
0
        /// <summary>
        /// Detects the payload kind(s) from the message stream.
        /// </summary>
        /// <param name="messageStream">The message stream to read from for payload kind detection.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>An enumerable of zero or one payload kinds depending on whether the metadata payload kind was detected or not.</returns>
        private static IEnumerable <ODataPayloadKind> DetectPayloadKindImplementation(Stream messageStream, ODataPayloadKindDetectionInfo detectionInfo)
        {
            try
            {
                using (XmlReader reader = ODataAtomReaderUtils.CreateXmlReader(messageStream, detectionInfo.GetEncoding(), detectionInfo.MessageReaderSettings))
                {
                    if (reader.TryReadToNextElement() && string.CompareOrdinal(EdmConstants.EdmxName, reader.LocalName) == 0)
                    {
                        switch (reader.NamespaceURI)
                        {
                        case EdmConstants.EdmxVersion1Namespace:
                        case EdmConstants.EdmxVersion2Namespace:
                        case EdmConstants.EdmxVersion3Namespace:
                            return(new ODataPayloadKind[] { ODataPayloadKind.MetadataDocument });
                        }
                    }
                }
            }
            catch (XmlException)
            {
                // If we are not able to read the payload as XML it is not a metadata document.
                // Return no detected payload kind below.
            }

            return(Enumerable.Empty <ODataPayloadKind>());
        }
コード例 #31
0
ファイル: ODataMetadataFormat.cs プロジェクト: nickchal/pash
 internal override Task<IEnumerable<ODataPayloadKind>> DetectPayloadKindAsync(IODataRequestMessageAsync requestMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull<IODataRequestMessageAsync>(requestMessage, "requestMessage");
     ExceptionUtils.CheckArgumentNotNull<ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     return TaskUtils.GetCompletedTask<IEnumerable<ODataPayloadKind>>(Enumerable.Empty<ODataPayloadKind>());
 }
コード例 #32
0
 internal override Task <IEnumerable <ODataPayloadKind> > DetectPayloadKindAsync(IODataResponseMessageAsync responseMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull <IODataResponseMessageAsync>(responseMessage, "responseMessage");
     ExceptionUtils.CheckArgumentNotNull <ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     return(((ODataMessage)responseMessage).GetStreamAsync().FollowOnSuccessWith <Stream, IEnumerable <ODataPayloadKind> >(streamTask => DetectPayloadKindImplementation(streamTask.Result, detectionInfo)));
 }
コード例 #33
0
        /// <summary>
        /// Detects the payload kind(s) from the message stream.
        /// </summary>
        /// <param name="messageStream">The message stream to read from for payload kind detection.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>An enumerable of zero or one payload kinds depending on whether the metadata payload kind was detected or not.</returns>
        private static IEnumerable<ODataPayloadKind> DetectPayloadKindImplementation(Stream messageStream, ODataPayloadKindDetectionInfo detectionInfo)
        {
            try
            {
                using (XmlReader reader = ODataAtomReaderUtils.CreateXmlReader(messageStream, detectionInfo.GetEncoding(), detectionInfo.MessageReaderSettings))
                {
                    if (reader.TryReadToNextElement() && string.CompareOrdinal(EdmConstants.EdmxName, reader.LocalName) == 0)
                    {
                        switch (reader.NamespaceURI)
                        {
                            case EdmConstants.EdmxVersion1Namespace:
                            case EdmConstants.EdmxVersion2Namespace:
                            case EdmConstants.EdmxVersion3Namespace:
                                return new ODataPayloadKind[] { ODataPayloadKind.MetadataDocument };
                        }
                    }
                }
            }
            catch (XmlException)
            {
                // If we are not able to read the payload as XML it is not a metadata document.
                // Return no detected payload kind below.
            }

            return Enumerable.Empty<ODataPayloadKind>();
        }
コード例 #34
0
ファイル: ODataBatchFormat.cs プロジェクト: nickchal/pash
 internal override Task<IEnumerable<ODataPayloadKind>> DetectPayloadKindAsync(IODataResponseMessageAsync responseMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull<IODataResponseMessageAsync>(responseMessage, "responseMessage");
     ExceptionUtils.CheckArgumentNotNull<ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     return TaskUtils.GetTaskForSynchronousOperation<IEnumerable<ODataPayloadKind>>(() => DetectPayloadKindImplementation(detectionInfo.ContentType));
 }
コード例 #35
0
 private static IEnumerable <ODataPayloadKind> DetectPayloadKindImplementation(Stream messageStream, ODataPayloadKindDetectionInfo detectionInfo)
 {
     try
     {
         using (XmlReader reader = ODataAtomReaderUtils.CreateXmlReader(messageStream, detectionInfo.GetEncoding(), detectionInfo.MessageReaderSettings))
         {
             string str;
             if (((reader.TryReadToNextElement() && (string.CompareOrdinal("Edmx", reader.LocalName) == 0)) && ((str = reader.NamespaceURI) != null)) && (((str == "http://schemas.microsoft.com/ado/2007/06/edmx") || (str == "http://schemas.microsoft.com/ado/2008/10/edmx")) || (str == "http://schemas.microsoft.com/ado/2009/11/edmx")))
             {
                 return(new ODataPayloadKind[] { ODataPayloadKind.MetadataDocument });
             }
         }
     }
     catch (XmlException)
     {
     }
     return(Enumerable.Empty <ODataPayloadKind>());
 }