-
Notifications
You must be signed in to change notification settings - Fork 0
OutputEditors
Albert-Jan Nijburg edited this page May 15, 2013
·
3 revisions
You can add an OutputEditor like this:
client.GetProducts.Out = new Func<ClientRequest>(() => {
var request = new ClientRequest();
request.Headers.Add("apikey", "1235467890");
return request;
});
client.GetProducts();or when you want to add a header from the function parameters.
client.GetProducts.Out = new Func<string, ClientRequest>(apikey => {
var request = new ClientRequest();
request.Headers.Add("apikey", apikey);
return request;
});
client.GetProducts("1234567890");you can also serialize an object from the function paramters like this for a post or put request.
client.PutProducts.Out = new Func<Product, ClientRequest>(product => {
var serializer = new XmlSerializer(typeof(Product));
var request = new ClientRequest();
usign (var ms = new MemoryStream()){
serializer.Serialize(product, ms);
}
request.Body = ms.ToArray();
return request;
});
client.PutProducts(new Product{
ProductID = 5,
Name = "Bananas",
Price = 5.87f
});And you can add an OutputEditor via a parameter to the function call like this:
client.GetProducs(new Func<Request>(() => new Request().Headers.Add("apikey","12334567890"));