本文整理汇总了C#中Order.ToJson方法的典型用法代码示例。如果您正苦于以下问题:C# Order.ToJson方法的具体用法?C# Order.ToJson怎么用?C# Order.ToJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order.ToJson方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: sendorder
/// <summary>
/// sends an order
/// </summary>
/// <param name="o"></param>
public virtual void sendorder(Order o)
{
send_event(MimeType.send_order, "order", o.ToJson());
o.VirtualOwner = ID; if (SendOrderEvent != null) SendOrderEvent(o, ID);
}
示例2: TestSerializeOrder
public void TestSerializeOrder()
{
var order = new Order
{
Customer = "John",
OrderDetails = new[]
{
new OrderDetail { Product = "Pen", Quantity = 1 },
new OrderDetail { Product = "Ruler", Quantity = 2 }
}
};
var json = order.ToJson();
var expected = "{ 'Customer' : 'John', 'OrderDetails' : # }";
expected = expected.Replace("#", "[{ 'Product' : 'Pen', 'Quantity' : 1 }, { 'Product' : 'Ruler', 'Quantity' : 2 }]");
expected = expected.Replace("'", "\"");
Assert.AreEqual(expected, json);
var bson = order.ToBson();
var rehydrated = BsonSerializer.Deserialize<Order>(bson);
Assert.IsTrue(bson.SequenceEqual(rehydrated.ToBson()));
}
示例3: GotOrder
/// <summary>
/// Called when new orders received
/// track or respond to orders here, eg:
/// this.MyOrders.Add(order);
/// </summary>
/// <param name="order"></param>
public virtual void GotOrder(Order o)
{
send_event(MimeType.got_order, "order", o.ToJson());
}