public static IHostBuilder UseExactlyOnceWebMachineInterface <T>(this IHostBuilder hostBuilder,
                                                                         IApplicationStateStore <T> applicationStateContainer,
                                                                         IMachineWebInterfaceRequestStore requestStore,
                                                                         IMachineWebInterfaceResponseStore responseStore,
                                                                         IMessageStore messageStore)
        {
            hostBuilder.ConfigureServices((ctx, serviceCollection) =>
            {
                serviceCollection.AddSingleton <IMachineInterfaceConnector <T> >(serviceProvider =>
                {
                    var dispatcher         = serviceProvider.GetService <IDispatchMessages>();
                    var rootMessageSession = serviceProvider.GetService <IMessageSession>();

                    var connector = new MachineInterfaceConnector <T>(
                        applicationStateContainer,
                        new ISideEffectsHandler[0],
                        rootMessageSession,
                        dispatcher,
                        messageStore,
                        requestStore,
                        responseStore);

                    return(connector);
                });
            });


            return(hostBuilder);
        }
 public HttpResponseSideEffectsHandler(
     IMachineWebInterfaceRequestStore requestStore,
     IMachineWebInterfaceResponseStore responseStore)
 {
     this.requestStore  = requestStore;
     this.responseStore = responseStore;
 }
        public MachineInterfaceConnector(IApplicationStateStore <T> applicationStateStore,
                                         IEnumerable <ISideEffectsHandler> sideEffectsHandlers,
                                         IMessageSession rootMessageSession,
                                         IDispatchMessages dispatcher,
                                         IMessageStore messageStore,
                                         IMachineWebInterfaceRequestStore requestStore,
                                         IMachineWebInterfaceResponseStore responseStore)
        {
            this.applicationStateStore = applicationStateStore;
            this.rootMessageSession    = rootMessageSession;
            this.messageStore          = messageStore;
            this.requestStore          = requestStore;
            this.responseStore         = responseStore;

            var allHandlers = sideEffectsHandlers.Concat(new ISideEffectsHandler[]
            {
                new WebMessagingWithClaimCheckSideEffectsHandler(messageStore, dispatcher),
                new HttpResponseSideEffectsHandler(requestStore, responseStore),
            });

            processor = new ExactlyOnceProcessor <object>(allHandlers.ToArray(), new NServiceBusDebugLogger());
        }