-
Notifications
You must be signed in to change notification settings - Fork 0
OutputEditors
Albert-Jan Nijburg edited this page May 14, 2013
·
3 revisions
You can add an OutputEditor like this:
client.GetProducts.Out = new Func<ClientRequest>(() => {
var request = new ClientRequest();
request.Headers = new Dictionary<string,string>() { "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 = new Dictionary<string,string>() { "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.GetProducts.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
});