Esempio n. 1
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. 2
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);
            }
        }