示例#1
0
        private void InitService()
        {
            ServiceBus bus = new ServiceBus();
            EventStore eventStore = new EventStore(bus);
            var repository = new Repository<InventoryItem>(eventStore);
            var commands = new CommandHandler<InventoryItem>(repository);

            bus.RegisterHandler<CreateInventoryItem>(commands.Create);
            bus.RegisterHandler<DeleteInventoryItem>(commands.Delete);

            var detail = new InventoryItemCreatedHandle();
            bus.RegisterHandler<InventoryItemCreated>(detail.Create);
            bus.RegisterHandler<ItemsDeletedFromInventory>(detail.Delete);
            bus.RegisterHandler<InventoryItemRenamed>(detail.Update);


            ServiceLocator.Bus = bus;
        }
示例#2
0
        private void InitService()
        {
            ServiceBus bus        = new ServiceBus();
            EventStore eventStore = new EventStore(bus);
            var        repository = new Repository <InventoryItem>(eventStore);
            var        commands   = new CommandHandler <InventoryItem>(repository);

            bus.RegisterHandler <CreateInventoryItem>(commands.Create);
            bus.RegisterHandler <DeleteInventoryItem>(commands.Delete);

            var detail = new InventoryItemCreatedHandle();

            bus.RegisterHandler <InventoryItemCreated>(detail.Create);
            bus.RegisterHandler <ItemsDeletedFromInventory>(detail.Delete);
            bus.RegisterHandler <InventoryItemRenamed>(detail.Update);


            ServiceLocator.Bus = bus;
        }