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 class Program | |
{ | |
static void Main(string[] args) | |
{ | |
EdmEntityType customer = new EdmEntityType("ns", "customer"); | |
var key = customer.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32); | |
customer.AddKeys(key); | |
customer.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String); | |
ODataEntry entry1 = new ODataEntry() |
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
public class CsvMediaTypeResolver : ODataMediaTypeResolver | |
{ | |
private static readonly CsvMediaTypeResolver instance = new CsvMediaTypeResolver(); | |
private readonly ODataMediaTypeFormat[] mediaTypeFormats = | |
{ | |
new ODataMediaTypeFormat(new ODataMediaType("text", "csv"), new CsvFormat()) | |
}; | |
private CsvMediaTypeResolver() { } |
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
public class CsvFormat : ODataFormat | |
{ | |
public override ODataOutputContext CreateOutputContext(ODataMessageInfo messageInfo, ODataMessageWriterSettings messageWriterSettings) | |
{ | |
return new CsvOutputContext(this, messageWriterSettings, messageInfo, synchronous: true); | |
} | |
} |
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 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 class CsvWriter : ODataWriter | |
{ | |
private CsvOutputContext context; | |
private List<string> headers; | |
public CsvWriter(CsvOutputContext context, IEdmEntityType entityType) | |
{ | |
this.context = context; | |
this.WriteHeader(entityType); | |
} |
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
class StringRepResolver : ODataUriResolver | |
{ | |
public override void PromoteBinaryOperandTypes( | |
BinaryOperatorKind binaryOperatorKind, | |
ref SingleValueNode leftNode, | |
ref SingleValueNode rightNode, | |
out IEdmTypeReference typeReference) | |
{ | |
if (binaryOperatorKind == BinaryOperatorKind.Multiply | |
&& leftNode.TypeReference != null |
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
var parser = new ODataUriParser( | |
extModel.Model, | |
ServiceRoot, | |
new Uri("http://demo/odata.svc/PetSet(Id=1, Color=TestNS.Color'Blue')/TestNS.HasColor(col=TestNS.Color'Blue')")); | |
var path = parser.ParsePath(); | |
var parser2 = new ODataUriParser( | |
extModel.Model, | |
ServiceRoot, | |
new Uri("http://demo/odata.svc/petset(id=1, color='Blue')/hascolor(COL='Blue')")) |
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
var parser = new ODataUriParser( | |
extModel.Model, | |
ServiceRoot, | |
new Uri("http://demo/odata.svc/GetColorCmykImport(col=TestNS.Color'Blue')")); | |
var path = parser.ParsePath(); | |
var parser2 = new ODataUriParser( | |
extModel.Model, | |
ServiceRoot, |
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
var parser = new ODataUriParser( | |
extModel.Model, | |
ServiceRoot, | |
new Uri("http://demo/odata.svc/People(1)/Addr/TestNS.GetZip")); | |
var path = parser.ParsePath(); | |
var parser2 = new ODataUriParser( | |
extModel.Model, | |
ServiceRoot, |
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
var parser = new ODataUriParser( | |
extModel.Model, | |
ServiceRoot, | |
new Uri("http://demo/odata.svc/People(1)/Pets/TestNS.Fish?$orderby=Color")); | |
var path = parser.ParsePath(); | |
var clause = parser.ParseOrderBy(); | |
var parser2 = new ODataUriParser( | |
extModel.Model, |
NewerOlder