public RequestContextManager(IHttpContextAccessor httpContextAccessor,
                                     RequestIdFromHttpContextProvider requestIdFromHttpContextProvider,
                                     Dictionary <RequestId, object> request2BoundedContextId,
                                     Dictionary <RequestId, RequestMetadata> request2RequestMetadata)
        {
            this.requestContext = new AsyncLocal <RequestContext>();

            this.httpContextAccessor = httpContextAccessor;
            this.requestIdFromHttpContextProvider = requestIdFromHttpContextProvider;
            this.request2BoundedContextId         = request2BoundedContextId;
            this.request2RequestMetadata          = request2RequestMetadata;
        }
Exemple #2
0
        private static RequestContextManager CreateRequestContextAccessor(IServiceCollection services,
                                                                          BoundedContextManager boundedContextManager, RequestIdFromHttpContextProvider requestIdFromHttpContextAccessor,
                                                                          ServiceProvider serviceProvider)
        {
            RequestCollections requestCollections = boundedContextManager.CreateRequestCollections();

            var requestContextManager = new RequestContextManager(serviceProvider.GetService <IHttpContextAccessor>(),
                                                                  requestIdFromHttpContextAccessor, requestCollections.Request2BoundedContextId,
                                                                  requestCollections.Request2RequestMetadata);

            services.AddSingleton <IRequestContextAccessor>(requestContextManager);

            return(requestContextManager);
        }