本文整理汇总了C#中Product.GetChanges方法的典型用法代码示例。如果您正苦于以下问题:C# Product.GetChanges方法的具体用法?C# Product.GetChanges怎么用?C# Product.GetChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.GetChanges方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DomainEventQuerySpec
public DomainEventQuerySpec()
{
var product = new Product(5, "DevStore");
product.Publish(1);
product.Publish(2);
product.Publish(3);
product.GetChanges().ToList()
.ForEach(e => store.Save(product, e));
product = new Product(6, "WoVS");
product.Publish(1);
product.Publish(2);
product.GetChanges().ToList()
.ForEach(e => store.Save(product, e));
}
示例2: WhenEventPersisted_ThenCanObserveIt
public void WhenEventPersisted_ThenCanObserveIt()
{
var store = new MemoryEventStore<int>();
var product = new Product(5, "DevStore");
product.Publish(1);
product.Publish(2);
product.Publish(3);
product.GetChanges().ToList()
.ForEach(e => store.Save(product, e));
product = new Product(6, "WoVS");
product.Publish(1);
product.Publish(2);
product.GetChanges().ToList()
.ForEach(e => store.Save(product, e));
var product2 = new Product();
product2.Load(store.Query().For<Product>(6));
Assert.Equal(product.Id, product2.Id);
Assert.Equal(product.Version, product2.Version);
var events = store.Query().For<Product>(5).OfType<Product.PublishedEvent>();
Assert.Equal(3, events.Count());
Console.WriteLine("For product 5, of type published:");
foreach (var e in events)
{
Console.WriteLine("\t" + e);
}
events = store.Query().For<Product>().OfType<Product.PublishedEvent>();
Assert.Equal(5, events.Count());
Console.WriteLine();
Console.WriteLine("For all products, of type published:");
foreach (var e in events)
{
Console.WriteLine("\t" + e);
}
events = store.Query().For<Product>();
Assert.Equal(7, events.Count());
Console.WriteLine();
Console.WriteLine("For all products, all event types:");
foreach (var e in events)
{
Console.WriteLine("\t" + e);
}
events = store.Query().OfType<Product.CreatedEvent>();
Assert.Equal(2, events.Count());
Console.WriteLine();
Console.WriteLine("Products created events:");
foreach (var e in events)
{
Console.WriteLine("\t" + e);
}
//product.Load(store.Events.For<Product>(23));
//var player = new DomainEventPlayer(store);
//player.Observe<ProductPublishedEvent>();
//player.Replay(from: null, to: null);
//store.Events.Where(
//store.Events.Where(x => x.AggregateType == "Product" &&
// x.EventType == "Published");
}