Esempio n. 1
0
        public static ODataMessageWriter CreateMessageWriter(
            Stream stream,
            string contenttype = "application/json",
            ODataMediaTypeResolver resolver = null,
            IEdmModel model = null,
            bool isResponse = true)
        {
            var message = new InMemoryMessage {
                Stream = stream
            };

            message.SetHeader("Content-Type", contenttype);
            var messageSettings = new ODataMessageWriterSettings
            {
                MediaTypeResolver            = resolver ?? new ODataMediaTypeResolver(),
                DisableMessageStreamDisposal = true,
                Indent = true,
            };

            if (isResponse)
            {
                return(new ODataMessageWriter((IODataResponseMessage)message, messageSettings, model));
            }
            else
            {
                return(new ODataMessageWriter((IODataRequestMessage)message, messageSettings, model));
            }
        }
Esempio n. 2
0
        public static ODataMessageReader CreateMessageReader(
            Stream stream,
            string contenttype = "application/json",
            ODataMediaTypeResolver resolver = null,
            IEdmModel model = null,
            bool isResponse = false)
        {
            var message = new InMemoryMessage {
                Stream = stream
            };

            message.SetHeader("Content-Type", contenttype);
            var messageSettings = new ODataMessageReaderSettings()
            {
                MediaTypeResolver       = resolver ?? new ODataMediaTypeResolver(),
                ShouldIncludeAnnotation = st => true,
            };

            if (isResponse)
            {
                return(new ODataMessageReader((IODataResponseMessage)message, messageSettings, model));
            }
            else
            {
                return(new ODataMessageReader((IODataRequestMessage)message, messageSettings, model));
            }
        }
Esempio n. 3
0
        public static ODataMessageWriter CreateMessageWriter(
            Stream stream,
            IServiceProvider container,
            string contenttype = "application/json",
            IEdmModel model    = null,
            bool isResponse    = true)
        {
            var message = new InMemoryMessage {
                Stream = stream, Container = container
            };

            message.SetHeader("Content-Type", contenttype);
            var messageSettings = new ODataMessageWriterSettings
            {
                EnableMessageStreamDisposal = false,
            };

            // Have untyped value in test
            messageSettings.Validations &= ~ValidationKinds.ThrowOnUndeclaredPropertyForNonOpenType;

            if (isResponse)
            {
                return(new ODataMessageWriter((IODataResponseMessage)message, messageSettings, model));
            }
            else
            {
                return(new ODataMessageWriter((IODataRequestMessage)message, messageSettings, model));
            }
        }
Esempio n. 4
0
        public static ODataMessageReader CreateMessageReader(
           Stream stream,
           string contenttype = "application/json",
           ODataMediaTypeResolver resolver = null,
           IEdmModel model = null,
           bool isResponse = false)
        {
            var message = new InMemoryMessage { Stream = stream };
            message.SetHeader("Content-Type", contenttype);
            var messageSettings = new ODataMessageReaderSettings()
            {
                MediaTypeResolver = resolver ?? new ODataMediaTypeResolver(),
                ShouldIncludeAnnotation = st => true,
            };

            if (isResponse)
            {
                return new ODataMessageReader((IODataResponseMessage)message, messageSettings, model);
            }
            else
            {
                return new ODataMessageReader((IODataRequestMessage)message, messageSettings, model);
            }
        }
Esempio n. 5
0
        public static ODataMessageWriter CreateMessageWriter(
           Stream stream,
           string contenttype = "application/json",
           ODataMediaTypeResolver resolver = null,
           IEdmModel model = null,
           bool isResponse = true)
        {
            var message = new InMemoryMessage { Stream = stream };
            message.SetHeader("Content-Type", contenttype);
            var messageSettings = new ODataMessageWriterSettings
            {
                MediaTypeResolver = resolver ?? new ODataMediaTypeResolver(),
                DisableMessageStreamDisposal = true,
                Indent = true,
            };

            if (isResponse)
            {
                return new ODataMessageWriter((IODataResponseMessage)message, messageSettings, model);
            }
            else
            {
                return new ODataMessageWriter((IODataRequestMessage)message, messageSettings, model);
            }
        }