当前位置: 首页>>代码示例>>C#>>正文


C# Product.GetChanges方法代码示例

本文整理汇总了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));
		}
开发者ID:netfx,项目名称:extensions,代码行数:15,代码来源:DomainEventQuerySpec.cs

示例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");
		}
开发者ID:netfx,项目名称:extensions,代码行数:71,代码来源:Sample.cs


注:本文中的Product.GetChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。