Closed ezet closed 8 years ago
I've added a possible implementation for passing parameters, as simple key/value string pairs that can be included in .Load() or .Query() calls.
Example:
var orders = crest.GetRoot().Query(r => r.Regions) .Query(x => x.Single(r => r.Name == "The Forge")) .Query(r => r.MarketBuyOrders, "type", "https://public-crest.eveonline.com/types/34/");
This isn't very safe tho as is very apt to typing bugs. It also allows partly user constructed URLs, which breaks some of the goals with CREST.
So should I perhaps disallow manual URLs like the example above, and do something like this:
var type = crest.GetRoot().Query(r => r.MarketTypes).Items.Single(r => r.Type.Id == 34); var orders = crest.GetRoot().Query(r => r.Regions) .Query(x => x.Single(r => r.Name == "The Forge")) .Query(r => r.MarketBuyOrders, "type", type);
Where you first need to get the type you want through CREST, and you pass that in directly? It would still be possible to construct URLs manually if you really wanted, but is more in line with the stated goals for CREST.
The parameter name is still manually typed, but I'm not sure if it is worth the hassle to enforce that with eg. enums or a parameter object for each name/value pair ? I'm open for input on how you would like this to be implemented :)
The first example is valid for the newest version on github if anyone wants to try it out. It allows an arbitrary amount of name/value pairs, and works for all types of resources that support it, eg. market types, market groups, and so on.
Use named parameters, crest.GetRoot.Query(r => r.resource, type = someType, model = customModel);
Implemented.
Need to add a way to pass Href objects in a query call.