Last active
August 29, 2015 14:12
-
-
Save ODataTeam/4d6b8b682c1f392bda5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal sealed class CsvOutputContext : ODataOutputContext | |
{ | |
private Stream stream; | |
public CsvOutputContext( | |
ODataFormat format, | |
ODataMessageWriterSettings settings, | |
ODataMessageInfo messageInfo, | |
bool synchronous) | |
: base(format, settings, messageInfo.IsResponse, synchronous, messageInfo.Model, messageInfo.UrlResolver) | |
{ | |
this.stream = messageInfo.GetMessageStream(); | |
this.Writer = new StreamWriter(this.stream); | |
} | |
public TextWriter Writer { get; private set; } | |
public override ODataWriter CreateODataEntryWriter(IEdmNavigationSource navigationSource, IEdmEntityType entityType) | |
{ | |
return new CsvWriter(this, entityType); | |
} | |
public override ODataWriter CreateODataFeedWriter(IEdmEntitySetBase entitySet, IEdmEntityType entityType) | |
{ | |
return new CsvWriter(this, entityType); | |
} | |
public void Flush() | |
{ | |
this.stream.Flush(); | |
} | |
protected override void Dispose(bool disposing) | |
{ | |
if (disposing) | |
{ | |
try | |
{ | |
if (this.Writer != null) | |
{ | |
this.Writer.Dispose(); | |
} | |
if (this.stream != null) | |
{ | |
this.stream.Dispose(); | |
} | |
} | |
finally | |
{ | |
this.Writer = null; | |
this.stream = null; | |
} | |
} | |
base.Dispose(disposing); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment