private ODataJsonOutputContext(ODataFormat format, Stream messageStream, Encoding encoding, ODataMessageWriterSettings messageWriterSettings, bool writingResponse, bool synchronous, IEdmModel model, IODataUrlResolver urlResolver) : base(format, messageWriterSettings, writingResponse, synchronous, model, urlResolver)
 {
     try
     {
         Stream asynchronousOutputStream;
         this.messageOutputStream = messageStream;
         if (synchronous)
         {
             asynchronousOutputStream = messageStream;
         }
         else
         {
             this.asynchronousOutputStream = new AsyncBufferedStream(messageStream);
             asynchronousOutputStream      = this.asynchronousOutputStream;
         }
         this.textWriter = new StreamWriter(asynchronousOutputStream, encoding);
         this.jsonWriter = new Microsoft.Data.OData.Json.JsonWriter(this.textWriter, messageWriterSettings.Indent);
     }
     catch (Exception exception)
     {
         if (ExceptionUtils.IsCatchableExceptionType(exception) && (messageStream != null))
         {
             messageStream.Dispose();
         }
         throw;
     }
 }
Esempio n. 2
0
 private ODataJsonOutputContext(ODataFormat format, Stream messageStream, Encoding encoding, ODataMessageWriterSettings messageWriterSettings, bool writingResponse, bool synchronous, IEdmModel model, IODataUrlResolver urlResolver) : base(format, messageWriterSettings, writingResponse, synchronous, model, urlResolver)
 {
     try
     {
         Stream asynchronousOutputStream;
         this.messageOutputStream = messageStream;
         if (synchronous)
         {
             asynchronousOutputStream = messageStream;
         }
         else
         {
             this.asynchronousOutputStream = new AsyncBufferedStream(messageStream);
             asynchronousOutputStream = this.asynchronousOutputStream;
         }
         this.textWriter = new StreamWriter(asynchronousOutputStream, encoding);
         this.jsonWriter = new Microsoft.Data.OData.Json.JsonWriter(this.textWriter, messageWriterSettings.Indent);
     }
     catch (Exception exception)
     {
         if (ExceptionUtils.IsCatchableExceptionType(exception) && (messageStream != null))
         {
             messageStream.Dispose();
         }
         throw;
     }
 }
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     try
     {
         if (this.messageOutputStream != null)
         {
             this.jsonWriter.Flush();
             if (this.asynchronousOutputStream != null)
             {
                 this.asynchronousOutputStream.FlushSync();
                 this.asynchronousOutputStream.Dispose();
             }
             this.messageOutputStream.Dispose();
         }
     }
     finally
     {
         this.messageOutputStream      = null;
         this.asynchronousOutputStream = null;
         this.textWriter = null;
         this.jsonWriter = null;
     }
 }
Esempio n. 4
0
 private ODataJsonOutputContext(ODataFormat format, Microsoft.Data.OData.Json.JsonWriter jsonWriter, ODataMessageWriterSettings messageWriterSettings, bool writingResponse, bool synchronous, IEdmModel model, IODataUrlResolver urlResolver) : base(format, messageWriterSettings, writingResponse, synchronous, model, urlResolver)
 {
     this.jsonWriter = jsonWriter;
 }
Esempio n. 5
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     try
     {
         if (this.messageOutputStream != null)
         {
             this.jsonWriter.Flush();
             if (this.asynchronousOutputStream != null)
             {
                 this.asynchronousOutputStream.FlushSync();
                 this.asynchronousOutputStream.Dispose();
             }
             this.messageOutputStream.Dispose();
         }
     }
     finally
     {
         this.messageOutputStream = null;
         this.asynchronousOutputStream = null;
         this.textWriter = null;
         this.jsonWriter = null;
     }
 }
 internal static ODataJsonOutputContext Create(ODataFormat format, Microsoft.Data.OData.Json.JsonWriter jsonWriter, ODataMessageWriterSettings messageWriterSettings, bool writingResponse, IEdmModel model, IODataUrlResolver urlResolver)
 {
     return(new ODataJsonOutputContext(format, jsonWriter, messageWriterSettings, writingResponse, true, model, urlResolver));
 }
 private ODataJsonOutputContext(ODataFormat format, Microsoft.Data.OData.Json.JsonWriter jsonWriter, ODataMessageWriterSettings messageWriterSettings, bool writingResponse, bool synchronous, IEdmModel model, IODataUrlResolver urlResolver) : base(format, messageWriterSettings, writingResponse, synchronous, model, urlResolver)
 {
     this.jsonWriter = jsonWriter;
 }