Пример #1
0
 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);
     }
 }
Пример #2
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>();
 }
Пример #3
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>();
        }
Пример #4
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>());
 }
Пример #5
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>());
        }