本文整理汇总了C#中Payload.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# Payload.AddRange方法的具体用法?C# Payload.AddRange怎么用?C# Payload.AddRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Payload
的用法示例。
在下文中一共展示了Payload.AddRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public Order Create(String reference, Option shippingOption, NameAndAddress shipTo, ProductShippingInfo product)
{
var uri = Map("/orders");
var payload = new Payload {
new Field { Name = "ref", Value = reference },
new Field { Name = "shipping_option_code", Value = shippingOption.Code },
};
payload.AddRange(Format(product));
payload.AddRange(Format(shipTo));
var response = Post(uri, payload);
if (response.StatusCode != HttpStatusCode.OK)
throw Error("Failed to create order", response);
var json = ReadAll(response);
var theOrderNode = new Deserializer().Deserialize(json)["order"];
return OrderDeserializer.Deserialize(theOrderNode.ToString());
}
示例2: ToPayload
private Payload ToPayload(ProductSeed seed, params Design[] designs)
{
var payload = new Payload {
{ "name", seed.Name},
{ "notes", seed.Notes},
{ "ref", seed.Reference}
};
foreach (var design in designs) {
payload.AddRange(ToFields(design));
payload.Add(
"designs[][uploaded_data]",
new DataItem(new FileInfo(design.Filename), "xxx")
);
}
return payload;
}