public void Init() { var repository = new BooRepository(null, null); _queries = new Query[Count]; _queriesStruct = new Ping[Count]; _requests = new GetBooRequest[Count]; _requestsStruct = new StructRequest[Count]; for (var i = 0; i < Count; i++) { repository.AddElement(new Boo { Id = i, Int = i }); _queries[i] = new Query(i); _queriesStruct[i] = new Ping(i); _requests[i] = new GetBooRequest { Id = i }; _requestsStruct[i] = new StructRequest(i.ToString()); } _mediator = MediatorBuilder.BuildMediatR(repository); _mediatorWithBehaviour = MediatorBuilder.BuildMediatR(repository, services => services.AddSingleton <GetBooRequestBehaviour>()); _mediatorWithFullPipeline = MediatorBuilder.BuildMediatR(repository, services => services .AddSingleton(typeof(IPipelineBehavior <,>), typeof(RequestPreProcessorBehavior <,>)) .AddSingleton(typeof(IPipelineBehavior <,>), typeof(RequestPostProcessorBehavior <,>)) .AddSingleton <IPipelineBehavior <GetBooRequest, Boo>, GetBooRequestBehaviour>() .AddSingleton <IRequestPreProcessor <GetBooRequest>, GetBooPreProcessor>() .AddSingleton <IRequestPostProcessor <GetBooRequest, Boo>, GetBooPostProcessor>()); _emitter = _emitterWithBehaviour = MediatorBuilder.BuildEmitter(repository); _emitterWithBehaviour = MediatorBuilder.BuildEmitter(repository, services => services.AddQueryBehaviour <Behaviour>()); _emitterWithFullPipeline = MediatorBuilder.BuildEmitter(repository, services => services .AddQueryBehaviour <Behaviour>() .AddQueryProcessor <PreProcessor>() .AddQueryProcessor <PostProcessor>()); }
public void Init() { _emitterNotifications = new PlusNotification[Count]; _mediatorNotifications = new Notification[Count]; for (var i = 0; i < Count; i++) { _emitterNotifications[i] = new PlusNotification(); _mediatorNotifications[i] = new Notification(); } var repository = new BooRepository(null, null); _mediator = MediatorBuilder.BuildMediatR(repository, services => services .AddSingleton <INotificationHandler <Notification>, NotificationHandler>(), 5); _emitter = MediatorBuilder.BuildEmitter(repository, services => services .AddNotificationProcessor <PlusNotificationProcessor>(), 5); }